Compare commits

..

No commits in common. "develop" and "stable" have entirely different histories.

141 changed files with 3558 additions and 4258 deletions

View file

@ -1,11 +1,3 @@
Version 2022.09 (unreleased)
Friendica Core
Friendica Addons
Closed Issues
Version 2022.06 (2022-06-11) Version 2022.06 (2022-06-11)
Friendica Core Friendica Core
Added DA DK translation, updates to the translations DE, FR, HU, PL, RU, ZH CN [translation teams] Added DA DK translation, updates to the translations DE, FR, HU, PL, RU, ZH CN [translation teams]

View file

@ -1 +1 @@
2022.09-dev 2022.06

View file

@ -31,7 +31,7 @@ use Friendica\Model\Contact;
define('FRIENDICA_PLATFORM', 'Friendica'); define('FRIENDICA_PLATFORM', 'Friendica');
define('FRIENDICA_CODENAME', 'Giant Rhubarb'); define('FRIENDICA_CODENAME', 'Giant Rhubarb');
define('FRIENDICA_VERSION', '2022.09-dev'); define('FRIENDICA_VERSION', '2022.06');
define('DFRN_PROTOCOL_VERSION', '2.23'); define('DFRN_PROTOCOL_VERSION', '2.23');
define('NEW_TABLE_STRUCTURE_VERSION', 1288); define('NEW_TABLE_STRUCTURE_VERSION', 1288);

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 2022.09-dev (Giant Rhubarb) -- Friendica 2022.06 (Giant Rhubarb)
-- DB_UPDATE_VERSION 1470 -- DB_UPDATE_VERSION 1469
-- ------------------------------------------ -- ------------------------------------------
@ -1216,12 +1216,12 @@ CREATE TABLE IF NOT EXISTS `post-link` (
CREATE TABLE IF NOT EXISTS `post-media` ( CREATE TABLE IF NOT EXISTS `post-media` (
`id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID', `id` int unsigned NOT NULL auto_increment COMMENT 'sequential ID',
`uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri', `uri-id` int unsigned NOT NULL COMMENT 'Id of the item-uri table entry that contains the item uri',
`url` text NOT NULL COMMENT 'Media URL', `url` varbinary(511) NOT NULL COMMENT 'Media URL',
`type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type', `type` tinyint unsigned NOT NULL DEFAULT 0 COMMENT 'Media type',
`mimetype` varchar(60) COMMENT '', `mimetype` varchar(60) COMMENT '',
`height` smallint unsigned COMMENT 'Height of the media', `height` smallint unsigned COMMENT 'Height of the media',
`width` smallint unsigned COMMENT 'Width of the media', `width` smallint unsigned COMMENT 'Width of the media',
`size` mediumint unsigned COMMENT 'Media size', `size` int unsigned COMMENT 'Media size',
`preview` varbinary(255) COMMENT 'Preview URL', `preview` varbinary(255) COMMENT 'Preview URL',
`preview-height` smallint unsigned COMMENT 'Height of the preview picture', `preview-height` smallint unsigned COMMENT 'Height of the preview picture',
`preview-width` smallint unsigned COMMENT 'Width of the preview picture', `preview-width` smallint unsigned COMMENT 'Width of the preview picture',
@ -1234,7 +1234,7 @@ CREATE TABLE IF NOT EXISTS `post-media` (
`publisher-name` varchar(255) COMMENT 'Name of the publisher of the media', `publisher-name` varchar(255) COMMENT 'Name of the publisher of the media',
`publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media', `publisher-image` varbinary(255) COMMENT 'Image of the publisher of the media',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `uri-id-url` (`uri-id`,`url`(512)), UNIQUE INDEX `uri-id-url` (`uri-id`,`url`),
INDEX `uri-id-id` (`uri-id`,`id`), INDEX `uri-id-id` (`uri-id`,`id`),
FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE FOREIGN KEY (`uri-id`) REFERENCES `item-uri` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE
) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media'; ) DEFAULT COLLATE utf8mb4_general_ci COMMENT='Attached media';

View file

@ -82,7 +82,6 @@ General
../settings ../settings
--------- ---------
* o - Account * o - Account
* 2 - Two-factor authentication
* p - Profiles * p - Profiles
* t - Additional features * t - Additional features
* w - Social Networks * w - Social Networks

View file

@ -6,36 +6,36 @@ Attached media
Fields Fields
------ ------
| Field | Description | Type | Null | Key | Default | Extra | | Field | Description | Type | Null | Key | Default | Extra |
| --------------- | --------------------------------------------------------- | ------------------ | ---- | --- | ------- | -------------- | | --------------- | --------------------------------------------------------- | ----------------- | ---- | --- | ------- | -------------- |
| id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment | | id | sequential ID | int unsigned | NO | PRI | NULL | auto_increment |
| uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | | NULL | | | uri-id | Id of the item-uri table entry that contains the item uri | int unsigned | NO | | NULL | |
| url | Media URL | text | NO | | NULL | | | url | Media URL | varbinary(511) | NO | | NULL | |
| type | Media type | tinyint unsigned | NO | | 0 | | | type | Media type | tinyint unsigned | NO | | 0 | |
| mimetype | | varchar(60) | YES | | NULL | | | mimetype | | varchar(60) | YES | | NULL | |
| height | Height of the media | smallint unsigned | YES | | NULL | | | height | Height of the media | smallint unsigned | YES | | NULL | |
| width | Width of the media | smallint unsigned | YES | | NULL | | | width | Width of the media | smallint unsigned | YES | | NULL | |
| size | Media size | mediumint unsigned | YES | | NULL | | | size | Media size | int unsigned | YES | | NULL | |
| preview | Preview URL | varbinary(255) | YES | | NULL | | | preview | Preview URL | varbinary(255) | YES | | NULL | |
| preview-height | Height of the preview picture | smallint unsigned | YES | | NULL | | | preview-height | Height of the preview picture | smallint unsigned | YES | | NULL | |
| preview-width | Width of the preview picture | smallint unsigned | YES | | NULL | | | preview-width | Width of the preview picture | smallint unsigned | YES | | NULL | |
| description | | text | YES | | NULL | | | description | | text | YES | | NULL | |
| name | Name of the media | varchar(255) | YES | | NULL | | | name | Name of the media | varchar(255) | YES | | NULL | |
| author-url | URL of the author of the media | varbinary(255) | YES | | NULL | | | author-url | URL of the author of the media | varbinary(255) | YES | | NULL | |
| author-name | Name of the author of the media | varchar(255) | YES | | NULL | | | author-name | Name of the author of the media | varchar(255) | YES | | NULL | |
| author-image | Image of the author of the media | varbinary(255) | YES | | NULL | | | author-image | Image of the author of the media | varbinary(255) | YES | | NULL | |
| publisher-url | URL of the publisher of the media | varbinary(255) | YES | | NULL | | | publisher-url | URL of the publisher of the media | varbinary(255) | YES | | NULL | |
| publisher-name | Name of the publisher of the media | varchar(255) | YES | | NULL | | | publisher-name | Name of the publisher of the media | varchar(255) | YES | | NULL | |
| publisher-image | Image of the publisher of the media | varbinary(255) | YES | | NULL | | | publisher-image | Image of the publisher of the media | varbinary(255) | YES | | NULL | |
Indexes Indexes
------------ ------------
| Name | Fields | | Name | Fields |
| ---------- | ------------------------ | | ---------- | ------------------- |
| PRIMARY | id | | PRIMARY | id |
| uri-id-url | UNIQUE, uri-id, url(512) | | uri-id-url | UNIQUE, uri-id, url |
| uri-id-id | uri-id, id | | uri-id-id | uri-id, id |
Foreign Keys Foreign Keys
------------ ------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -1,160 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="1000px"
height="1000px"
viewBox="0 0 1000 1000"
version="1.1"
id="SVGRoot"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
sodipodi:docname="GoToSocial_icon1.svg"
inkscape:export-xdpi="95.999992"
inkscape:export-ydpi="95.999992">
<defs
id="defs5117">
<inkscape:path-effect
effect="spiro"
id="path-effect5760"
is_visible="true" />
<inkscape:path-effect
effect="spiro"
id="path-effect5756"
is_visible="true" />
<inkscape:path-effect
effect="spiro"
id="path-effect5752"
is_visible="true" />
<inkscape:path-effect
effect="spiro"
id="path-effect5748"
is_visible="true" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.70710678"
inkscape:cx="460.72691"
inkscape:cy="522.20279"
inkscape:document-units="px"
inkscape:current-layer="layer3"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1057"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1" />
<metadata
id="metadata5120">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="background"
inkscape:groupmode="layer"
id="layer1"
style="display:inline">
<rect
style="fill:#d0d0d0;fill-opacity:1;stroke:none;stroke-width:1.51092136;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal"
id="rect5876"
width="1000.0042"
height="1000"
x="0"
y="0" />
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="sloth"
style="display:inline">
<g
id="g5890"
transform="translate(-10)">
<path
sodipodi:nodetypes="ssscccs"
inkscape:connector-curvature="0"
id="path5762"
d="M 861.29285,497.07031 C 861.65556,665.3247 774.21642,807.40548 511.60027,807.86794 270.63622,808.29226 154.54309,691.2756 155.19024,504.19228 155.7289,348.47535 251.17288,227.4551 422.3176,205.3802 c -35.32036,-75.85452 52.24232,-96.94648 73.77615,-32.00508 13.73451,-37.63439 108.24345,-49.1716 62.21106,24.77055 147.95052,3.75658 302.58353,111.28061 302.98804,298.92464 z"
style="display:inline;fill:#767676;fill-opacity:1;stroke:none;stroke-width:2.57058167;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<path
sodipodi:nodetypes="sssssss"
inkscape:connector-curvature="0"
id="path5780"
d="m 809.15213,517.31679 c -4.83374,150.52526 -109.85544,235.22815 -297.81171,235.31839 -179.6675,0.0863 -290.56109,-70.98245 -298.50223,-235.31839 -4.6366,-95.95095 54.62861,-181.84442 144.83016,-194.18834 80.92123,-11.07393 99.7402,21.01802 153.67207,21.01802 59.21658,0 83.64871,-35.09608 162.84221,-21.85479 87.78391,14.67763 137.90533,103.6017 134.9695,195.02511 z"
style="display:inline;fill:#e8e8e8;fill-opacity:1;stroke:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<path
sodipodi:nodetypes="scssscs"
inkscape:connector-curvature="0"
id="path5780-9"
d="m 809.15213,517.31679 c -1.32872,41.37724 -10.22787,77.78081 -26.33906,108.8204 -46.60931,-39.48031 -99.53509,-10.7281 -171.50115,-39.43334 -44.77145,-17.85808 -51.41659,-56.56453 -51.21999,-81.3542 0.54836,-69.14384 48.17003,-93.45758 95.53601,-97.60875 55.74677,-4.88566 124.5246,36.1482 151.01547,66.79433 2.11531,14.01083 2.97167,28.36512 2.50872,42.78156 z"
style="display:inline;fill:#a1a1a1;fill-opacity:1;stroke:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<ellipse
ry="50.575684"
rx="37.800804"
cy="502.64291"
cx="646.85773"
id="path5816"
style="fill:#767676;fill-opacity:1;stroke:none;stroke-width:1.51185882;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<path
sodipodi:nodetypes="scssscs"
inkscape:connector-curvature="0"
id="path5780-9-1"
d="m 212.51463,517.3246 c 1.32872,41.37724 10.22787,77.78081 26.33906,108.8204 46.60931,-39.48031 99.57415,-10.73591 171.54021,-39.44115 44.77145,-17.85808 51.41659,-56.56453 51.21999,-81.3542 -0.54836,-69.14384 -48.20909,-93.44977 -95.57507,-97.60094 -55.74677,-4.88566 -124.5246,36.1482 -151.01547,66.79433 -2.11531,14.01083 -2.97167,28.36512 -2.50872,42.78156 z"
style="display:inline;fill:#a1a1a1;fill-opacity:1;stroke:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<ellipse
transform="scale(-1,1)"
ry="50.575684"
rx="37.800804"
cy="502.64294"
cx="-374.84808"
id="path5816-0"
style="display:inline;fill:#767676;fill-opacity:1;stroke:none;stroke-width:1.51185882;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<path
sodipodi:nodetypes="sssss"
inkscape:connector-curvature="0"
id="path5862"
d="m 543.96613,556.96185 c 0,11.0622 -14.51648,20.02988 -32.42347,20.02988 -17.90698,0 -32.42347,-8.96769 -32.42347,-20.02988 0,-11.0622 14.14619,-15.58638 32.05318,-15.58638 17.90698,0 32.79376,4.52417 32.79376,15.58638 z"
style="display:inline;fill:#767676;fill-opacity:1;stroke:none;stroke-width:1.60515046;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<path
sodipodi:nodetypes="sssss"
inkscape:connector-curvature="0"
id="path5865"
d="m 552.00195,620.36132 c 7.06643,13.89391 -19.38375,21.24024 -40.2832,21.24024 -20.89945,0 -47.71708,-7.02219 -41.50391,-21.24024 5.71775,-13.08435 20.11619,0.73243 41.01563,0.73243 20.89944,0 34.43888,-13.1835 40.77148,-0.73243 z"
style="display:inline;fill:#767676;fill-opacity:1;stroke:none;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<ellipse
transform="rotate(-6.669407)"
ry="24.882849"
rx="19.511755"
cy="560.95673"
cx="600.24731"
id="path5818"
style="display:inline;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.53898752;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
<ellipse
transform="rotate(-6.6694071)"
ry="24.882849"
rx="19.511755"
cy="529.32086"
cx="329.69714"
id="path5818-8"
style="display:inline;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.53898752;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:normal" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View file

@ -157,9 +157,9 @@ function wall_upload_post(App $a, $desktopmode = true)
" - size: " . $filesize . " - type: " . $filetype); " - size: " . $filesize . " - type: " . $filetype);
$imagedata = @file_get_contents($src); $imagedata = @file_get_contents($src);
$image = new Image($imagedata, $filetype); $Image = new Image($imagedata, $filetype);
if (!$image->isValid()) { if (!$Image->isValid()) {
$msg = DI::l10n()->t('Unable to process image.'); $msg = DI::l10n()->t('Unable to process image.');
@unlink($src); @unlink($src);
if ($r_json) { if ($r_json) {
@ -170,18 +170,18 @@ function wall_upload_post(App $a, $desktopmode = true)
System::exit(); System::exit();
} }
$image->orient($src); $Image->orient($src);
@unlink($src); @unlink($src);
$max_length = DI::config()->get('system', 'max_image_length'); $max_length = DI::config()->get('system', 'max_image_length');
if ($max_length > 0) { if ($max_length > 0) {
$image->scaleDown($max_length); $Image->scaleDown($max_length);
$filesize = strlen($image->asString()); $filesize = strlen($Image->asString());
Logger::info("File upload: Scaling picture to new size " . $max_length); Logger::info("File upload: Scaling picture to new size " . $max_length);
} }
$width = $image->getWidth(); $width = $Image->getWidth();
$height = $image->getHeight(); $height = $Image->getHeight();
$maximagesize = DI::config()->get('system', 'maximagesize'); $maximagesize = DI::config()->get('system', 'maximagesize');
@ -190,10 +190,10 @@ function wall_upload_post(App $a, $desktopmode = true)
foreach ([5120, 2560, 1280, 640] as $pixels) { foreach ([5120, 2560, 1280, 640] as $pixels) {
if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) { if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) {
Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]); Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]);
$image->scaleDown($pixels); $Image->scaleDown($pixels);
$filesize = strlen($image->asString()); $filesize = strlen($Image->asString());
$width = $image->getWidth(); $width = $Image->getWidth();
$height = $image->getHeight(); $height = $Image->getHeight();
} }
} }
if ($filesize > $maximagesize) { if ($filesize > $maximagesize) {
@ -220,7 +220,7 @@ function wall_upload_post(App $a, $desktopmode = true)
$defperm = '<' . $default_cid . '>'; $defperm = '<' . $default_cid . '>';
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $defperm); $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 0, Photo::DEFAULT, $defperm);
if (!$r) { if (!$r) {
$msg = DI::l10n()->t('Image upload failed.'); $msg = DI::l10n()->t('Image upload failed.');
@ -233,16 +233,16 @@ function wall_upload_post(App $a, $desktopmode = true)
} }
if ($width > 640 || $height > 640) { if ($width > 640 || $height > 640) {
$image->scaleDown(640); $Image->scaleDown(640);
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $defperm); $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 1, Photo::DEFAULT, $defperm);
if ($r) { if ($r) {
$smallest = 1; $smallest = 1;
} }
} }
if ($width > 320 || $height > 320) { if ($width > 320 || $height > 320) {
$image->scaleDown(320); $Image->scaleDown(320);
$r = Photo::store($image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $defperm); $r = Photo::store($Image, $page_owner_uid, $visitor, $resource_id, $filename, $album, 2, Photo::DEFAULT, $defperm);
if ($r && ($smallest == 0)) { if ($r && ($smallest == 0)) {
$smallest = 2; $smallest = 2;
} }
@ -264,8 +264,8 @@ function wall_upload_post(App $a, $desktopmode = true)
$picture["height"] = $photo["height"]; $picture["height"] = $photo["height"];
$picture["type"] = $photo["type"]; $picture["type"] = $photo["type"];
$picture["albumpage"] = DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id; $picture["albumpage"] = DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id;
$picture["picture"] = DI::baseUrl() . "/photo/{$resource_id}-0." . $image->getExt(); $picture["picture"] = DI::baseUrl() . "/photo/{$resource_id}-0." . $Image->getExt();
$picture["preview"] = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt(); $picture["preview"] = DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $Image->getExt();
if ($r_json) { if ($r_json) {
System::jsonExit(['picture' => $picture]); System::jsonExit(['picture' => $picture]);
@ -280,7 +280,7 @@ function wall_upload_post(App $a, $desktopmode = true)
System::jsonExit(['ok' => true]); System::jsonExit(['ok' => true]);
} }
echo "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}." . $image->getExt() . "[/img][/url]\n\n"; echo "\n\n" . '[url=' . DI::baseUrl() . '/photos/' . $page_owner_nick . '/image/' . $resource_id . '][img]' . DI::baseUrl() . "/photo/{$resource_id}-{$smallest}.".$Image->getExt()."[/img][/url]\n\n";
System::exit(); System::exit();
// NOTREACHED // NOTREACHED
} }

View file

@ -145,7 +145,7 @@ class App
$this->nickname = $nickname; $this->nickname = $nickname;
} }
public function isLoggedIn(): bool public function isLoggedIn()
{ {
return local_user() && $this->user_id && ($this->user_id == local_user()); return local_user() && $this->user_id && ($this->user_id == local_user());
} }
@ -155,7 +155,7 @@ class App
* *
* @return bool true if user is an admin * @return bool true if user is an admin
*/ */
public function isSiteAdmin(): bool public function isSiteAdmin()
{ {
$admin_email = $this->config->get('config', 'admin_email'); $admin_email = $this->config->get('config', 'admin_email');
@ -166,18 +166,18 @@ class App
/** /**
* Fetch the user id * Fetch the user id
* @return int User id * @return int
*/ */
public function getLoggedInUserId(): int public function getLoggedInUserId()
{ {
return $this->user_id; return $this->user_id;
} }
/** /**
* Fetch the user nick name * Fetch the user nick name
* @return string User's nickname * @return string
*/ */
public function getLoggedInUserNickname(): string public function getLoggedInUserNickname()
{ {
return $this->nickname; return $this->nickname;
} }
@ -198,7 +198,7 @@ class App
* *
* @return int * @return int
*/ */
public function getProfileOwner(): int public function getProfileOwner():int
{ {
return $this->profile_owner; return $this->profile_owner;
} }
@ -219,7 +219,7 @@ class App
* *
* @return int * @return int
*/ */
public function getContactId(): int public function getContactId():int
{ {
return $this->contact_id; return $this->contact_id;
} }
@ -241,7 +241,7 @@ class App
* *
* @return int * @return int
*/ */
public function getTimeZone(): string public function getTimeZone():string
{ {
return $this->timezone; return $this->timezone;
} }
@ -260,9 +260,9 @@ class App
/** /**
* Fetch workerqueue information * Fetch workerqueue information
* *
* @return array Worker queue * @return array
*/ */
public function getQueue(): array public function getQueue()
{ {
return $this->queue ?? []; return $this->queue ?? [];
} }
@ -270,8 +270,8 @@ class App
/** /**
* Fetch a specific workerqueue field * Fetch a specific workerqueue field
* *
* @param string $index Work queue record to fetch * @param string $index
* @return mixed Work queue item or NULL if not found * @return mixed
*/ */
public function getQueueValue(string $index) public function getQueueValue(string $index)
{ {
@ -306,9 +306,9 @@ class App
/** /**
* The basepath of this app * The basepath of this app
* *
* @return string Base path from configuration * @return string
*/ */
public function getBasePath(): string public function getBasePath()
{ {
// Don't use the basepath of the config table for basepath (it should always be the config-file one) // Don't use the basepath of the config table for basepath (it should always be the config-file one)
return $this->config->getCache()->get('system', 'basepath'); return $this->config->getCache()->get('system', 'basepath');
@ -396,10 +396,10 @@ class App
/** /**
* Returns the current theme name. May be overriden by the mobile theme name. * Returns the current theme name. May be overriden by the mobile theme name.
* *
* @return string Current theme name or empty string in installation phase * @return string
* @throws Exception * @throws Exception
*/ */
public function getCurrentTheme(): string public function getCurrentTheme()
{ {
if ($this->mode->isInstall()) { if ($this->mode->isInstall()) {
return ''; return '';
@ -425,10 +425,10 @@ class App
/** /**
* Returns the current mobile theme name. * Returns the current mobile theme name.
* *
* @return string Mobile theme name or empty string if installer * @return string
* @throws Exception * @throws Exception
*/ */
public function getCurrentMobileTheme(): string public function getCurrentMobileTheme()
{ {
if ($this->mode->isInstall()) { if ($this->mode->isInstall()) {
return ''; return '';
@ -441,22 +441,12 @@ class App
return $this->currentMobileTheme; return $this->currentMobileTheme;
} }
/** public function setCurrentTheme($theme)
* Setter for current theme name
*
* @param string $theme Name of current theme
*/
public function setCurrentTheme(string $theme)
{ {
$this->currentTheme = $theme; $this->currentTheme = $theme;
} }
/** public function setCurrentMobileTheme($theme)
* Setter for current mobile theme name
*
* @param string $theme Name of current mobile theme
*/
public function setCurrentMobileTheme(string $theme)
{ {
$this->currentMobileTheme = $theme; $this->currentMobileTheme = $theme;
} }
@ -535,10 +525,10 @@ class App
/** /**
* Provide a sane default if nothing is chosen or the specified theme does not exist. * Provide a sane default if nothing is chosen or the specified theme does not exist.
* *
* @return string Current theme's stylsheet path * @return string
* @throws Exception * @throws Exception
*/ */
public function getCurrentThemeStylesheetPath(): string public function getCurrentThemeStylesheetPath()
{ {
return Core\Theme::getStylesheetPath($this->getCurrentTheme()); return Core\Theme::getStylesheetPath($this->getCurrentTheme());
} }
@ -740,7 +730,7 @@ class App
* *
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
public function redirect(string $toUrl) public function redirect($toUrl)
{ {
if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) { if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
Core\System::externalRedirect($toUrl); Core\System::externalRedirect($toUrl);

View file

@ -78,7 +78,7 @@ class Arguments
/** /**
* @return string The whole command of this call * @return string The whole command of this call
*/ */
public function getCommand(): string public function getCommand()
{ {
return $this->command; return $this->command;
} }
@ -94,7 +94,7 @@ class Arguments
/** /**
* @return array All arguments of this call * @return array All arguments of this call
*/ */
public function getArgv(): array public function getArgv()
{ {
return $this->argv; return $this->argv;
} }
@ -102,7 +102,7 @@ class Arguments
/** /**
* @return string The used HTTP method * @return string The used HTTP method
*/ */
public function getMethod(): string public function getMethod()
{ {
return $this->method; return $this->method;
} }
@ -110,7 +110,7 @@ class Arguments
/** /**
* @return int The count of arguments of this call * @return int The count of arguments of this call
*/ */
public function getArgc(): int public function getArgc()
{ {
return $this->argc; return $this->argc;
} }
@ -145,7 +145,7 @@ class Arguments
* *
* @return bool if the argument position exists * @return bool if the argument position exists
*/ */
public function has(int $position): bool public function has(int $position)
{ {
return array_key_exists($position, $this->argv); return array_key_exists($position, $this->argv);
} }
@ -158,7 +158,7 @@ class Arguments
* *
* @return Arguments The determined arguments * @return Arguments The determined arguments
*/ */
public function determine(array $server, array $get): Arguments public function determine(array $server, array $get)
{ {
// removing leading / - maybe a nginx problem // removing leading / - maybe a nginx problem
$server['QUERY_STRING'] = ltrim($server['QUERY_STRING'] ?? '', '/'); $server['QUERY_STRING'] = ltrim($server['QUERY_STRING'] ?? '', '/');

View file

@ -107,7 +107,7 @@ class BaseURL
* *
* @return string * @return string
*/ */
public function getHostname(): string public function getHostname()
{ {
return $this->hostname; return $this->hostname;
} }
@ -117,7 +117,7 @@ class BaseURL
* *
* @return string * @return string
*/ */
public function getScheme(): string public function getScheme()
{ {
return $this->scheme; return $this->scheme;
} }
@ -127,7 +127,7 @@ class BaseURL
* *
* @return int * @return int
*/ */
public function getSSLPolicy(): int public function getSSLPolicy()
{ {
return $this->sslPolicy; return $this->sslPolicy;
} }
@ -137,7 +137,7 @@ class BaseURL
* *
* @return string * @return string
*/ */
public function getUrlPath(): string public function getUrlPath()
{ {
return $this->urlPath; return $this->urlPath;
} }
@ -151,7 +151,7 @@ class BaseURL
* *
* @return string * @return string
*/ */
public function get(bool $ssl = false): string public function get($ssl = false)
{ {
if ($this->sslPolicy === self::SSL_POLICY_SELFSIGN && $ssl) { if ($this->sslPolicy === self::SSL_POLICY_SELFSIGN && $ssl) {
return Network::switchScheme($this->url); return Network::switchScheme($this->url);
@ -168,9 +168,8 @@ class BaseURL
* @param string? $urlPath * @param string? $urlPath
* *
* @return bool true, if successful * @return bool true, if successful
* @TODO Find proper types
*/ */
public function save($hostname = null, $sslPolicy = null, $urlPath = null): bool public function save($hostname = null, $sslPolicy = null, $urlPath = null)
{ {
$currHostname = $this->hostname; $currHostname = $this->hostname;
$currSSLPolicy = $this->sslPolicy; $currSSLPolicy = $this->sslPolicy;
@ -225,11 +224,11 @@ class BaseURL
/** /**
* Save the current url as base URL * Save the current url as base URL
* *
* @param string $url * @param $url
* *
* @return bool true, if the save was successful * @return bool true, if the save was successful
*/ */
public function saveByURL(string $url): bool public function saveByURL($url)
{ {
$parsed = @parse_url($url); $parsed = @parse_url($url);
@ -422,7 +421,7 @@ class BaseURL
* *
* @return string The cleaned url * @return string The cleaned url
*/ */
public function remove(string $origURL): string public function remove(string $origURL)
{ {
// Remove the hostname from the url if it is an internal link // Remove the hostname from the url if it is an internal link
$nurl = Strings::normaliseLink($origURL); $nurl = Strings::normaliseLink($origURL);
@ -446,7 +445,7 @@ class BaseURL
* *
* @throws HTTPException\InternalServerErrorException In Case the given URL is not relative to the Friendica node * @throws HTTPException\InternalServerErrorException In Case the given URL is not relative to the Friendica node
*/ */
public function redirect(string $toUrl = '', bool $ssl = false) public function redirect($toUrl = '', $ssl = false)
{ {
if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) { if (!empty(parse_url($toUrl, PHP_URL_SCHEME))) {
throw new HTTPException\InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo"); throw new HTTPException\InternalServerErrorException("'$toUrl is not a relative path, please use System::externalRedirectTo");
@ -459,8 +458,8 @@ class BaseURL
/** /**
* Returns the base url as string * Returns the base url as string
*/ */
public function __toString(): string public function __toString()
{ {
return (string) $this->get(); return $this->get();
} }
} }

View file

@ -130,7 +130,7 @@ class Mode
* *
* @throws \Exception * @throws \Exception
*/ */
public function determine(BasePath $basepath, Database $database, Cache $configCache): Mode public function determine(BasePath $basepath, Database $database, Cache $configCache)
{ {
$mode = 0; $mode = 0;
@ -178,7 +178,7 @@ class Mode
* *
* @return Mode returns the determined mode * @return Mode returns the determined mode
*/ */
public function determineRunMode(bool $isBackend, array $server, Arguments $args, MobileDetect $mobileDetect): Mode public function determineRunMode(bool $isBackend, array $server, Arguments $args, MobileDetect $mobileDetect)
{ {
foreach (self::BACKEND_CONTENT_TYPES as $type) { foreach (self::BACKEND_CONTENT_TYPES as $type) {
if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) { if (strpos(strtolower($server['HTTP_ACCEPT'] ?? ''), $type) !== false) {
@ -201,7 +201,7 @@ class Mode
* *
* @return bool returns true, if the mode is set * @return bool returns true, if the mode is set
*/ */
public function has(int $mode): bool public function has($mode)
{ {
return ($this->mode & $mode) > 0; return ($this->mode & $mode) > 0;
} }
@ -227,7 +227,7 @@ class Mode
* *
* @return int Execution Mode * @return int Execution Mode
*/ */
public function getExecutor(): int public function getExecutor()
{ {
return $this->executor; return $this->executor;
} }
@ -235,9 +235,9 @@ class Mode
/** /**
* Install mode is when the local config file is missing or the DB schema hasn't been installed yet. * Install mode is when the local config file is missing or the DB schema hasn't been installed yet.
* *
* @return bool Whether installation mode is active (local/database configuration files present or not) * @return bool
*/ */
public function isInstall(): bool public function isInstall()
{ {
return !$this->has(Mode::LOCALCONFIGPRESENT) || return !$this->has(Mode::LOCALCONFIGPRESENT) ||
!$this->has(MODE::DBCONFIGAVAILABLE); !$this->has(MODE::DBCONFIGAVAILABLE);
@ -248,7 +248,7 @@ class Mode
* *
* @return bool * @return bool
*/ */
public function isNormal(): bool public function isNormal()
{ {
return $this->has(Mode::LOCALCONFIGPRESENT) && return $this->has(Mode::LOCALCONFIGPRESENT) &&
$this->has(Mode::DBAVAILABLE) && $this->has(Mode::DBAVAILABLE) &&
@ -261,7 +261,7 @@ class Mode
* *
* @return bool Is it a backend call * @return bool Is it a backend call
*/ */
public function isBackend(): bool public function isBackend()
{ {
return $this->isBackend; return $this->isBackend;
} }
@ -271,7 +271,7 @@ class Mode
* *
* @return bool true if it was an AJAX request * @return bool true if it was an AJAX request
*/ */
public function isAjax(): bool public function isAjax()
{ {
return $this->isAjax; return $this->isAjax;
} }
@ -281,7 +281,7 @@ class Mode
* *
* @return bool true if it was an mobile request * @return bool true if it was an mobile request
*/ */
public function isMobile(): bool public function isMobile()
{ {
return $this->isMobile; return $this->isMobile;
} }
@ -291,7 +291,7 @@ class Mode
* *
* @return bool true if it was an tablet request * @return bool true if it was an tablet request
*/ */
public function isTablet(): bool public function isTablet()
{ {
return $this->isTablet; return $this->isTablet;
} }

View file

@ -195,7 +195,7 @@ class Page implements ArrayAccess
* @param string $media * @param string $media
* @see Page::initHead() * @see Page::initHead()
*/ */
public function registerStylesheet(string $path, string $media = 'screen') public function registerStylesheet($path, string $media = 'screen')
{ {
$path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]); $path = Network::appendQueryParam($path, ['v' => FRIENDICA_VERSION]);
@ -288,7 +288,7 @@ class Page implements ArrayAccess
* *
* Taken from http://webcheatsheet.com/php/get_current_page_url.php * Taken from http://webcheatsheet.com/php/get_current_page_url.php
*/ */
private function curPageURL(): string private function curPageURL()
{ {
$pageURL = 'http'; $pageURL = 'http';
if (!empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) { if (!empty($_SERVER["HTTPS"]) && ($_SERVER["HTTPS"] == "on")) {

View file

@ -152,7 +152,7 @@ class Router
* *
* @throws HTTPException\InternalServerErrorException In case of invalid configs * @throws HTTPException\InternalServerErrorException In case of invalid configs
*/ */
public function loadRoutes(array $routes): Router public function loadRoutes(array $routes)
{ {
$routeCollector = ($this->routeCollector ?? new RouteCollector(new Std(), new GroupCountBased())); $routeCollector = ($this->routeCollector ?? new RouteCollector(new Std(), new GroupCountBased()));
@ -166,13 +166,6 @@ class Router
return $this; return $this;
} }
/**
* Adds multiple routes to a route collector
*
* @param RouteCollector $routeCollector Route collector instance
* @param array $routes Multiple routes to be added
* @throws HTTPException\InternalServerErrorException If route was wrong (somehow)
*/
private function addRoutes(RouteCollector $routeCollector, array $routes) private function addRoutes(RouteCollector $routeCollector, array $routes)
{ {
foreach ($routes as $route => $config) { foreach ($routes as $route => $config) {
@ -228,7 +221,7 @@ class Router
* *
* @return bool * @return bool
*/ */
private function isRoute(array $config): bool private function isRoute(array $config)
{ {
return return
// The config array should at least have one entry // The config array should at least have one entry
@ -260,7 +253,7 @@ class Router
* @throws HTTPException\MethodNotAllowedException If a rule matched but the method didn't * @throws HTTPException\MethodNotAllowedException If a rule matched but the method didn't
* @throws HTTPException\NotFoundException If no rule matched * @throws HTTPException\NotFoundException If no rule matched
*/ */
private function getModuleClass(): string private function getModuleClass()
{ {
$cmd = $this->args->getCommand(); $cmd = $this->args->getCommand();
$cmd = '/' . ltrim($cmd, '/'); $cmd = '/' . ltrim($cmd, '/');

View file

@ -70,11 +70,9 @@ class BaseCollection extends \ArrayIterator
} }
/** /**
* Getter for total count * @return int
*
* @return int Total count
*/ */
public function getTotalCount(): int public function getTotalCount()
{ {
return $this->totalCount; return $this->totalCount;
} }
@ -87,7 +85,7 @@ class BaseCollection extends \ArrayIterator
* @return array * @return array
* @see array_column() * @see array_column()
*/ */
public function column(string $column, $index_key = null): array public function column($column, $index_key = null)
{ {
return array_column($this->getArrayCopy(true), $column, $index_key); return array_column($this->getArrayCopy(true), $column, $index_key);
} }
@ -99,7 +97,7 @@ class BaseCollection extends \ArrayIterator
* @return BaseCollection * @return BaseCollection
* @see array_map() * @see array_map()
*/ */
public function map(callable $callback): BaseCollection public function map(callable $callback)
{ {
return new static(array_map($callback, $this->getArrayCopy()), $this->getTotalCount()); return new static(array_map($callback, $this->getArrayCopy()), $this->getTotalCount());
} }
@ -112,7 +110,7 @@ class BaseCollection extends \ArrayIterator
* @return BaseCollection * @return BaseCollection
* @see array_filter() * @see array_filter()
*/ */
public function filter(callable $callback = null, int $flag = 0): BaseCollection public function filter(callable $callback = null, int $flag = 0)
{ {
return new static(array_filter($this->getArrayCopy(), $callback, $flag)); return new static(array_filter($this->getArrayCopy(), $callback, $flag));
} }

View file

@ -55,14 +55,14 @@ abstract class BaseEntity extends BaseDataTransferObject
} }
/** /**
* @param mixed $name * @param $name
* @return bool * @return bool
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
public function __isset($name): bool public function __isset($name)
{ {
if (!property_exists($this, $name)) { if (!property_exists($this, $name)) {
throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' of type ' . gettype($name) . ' in Entity ' . static::class); throw new HTTPException\InternalServerErrorException('Unknown property ' . $name . ' in Entity ' . static::class);
} }
return !empty($this->$name); return !empty($this->$name);

View file

@ -110,11 +110,11 @@ abstract class BaseModel extends BaseDataTransferObject
* - $model->field (outside of class) * - $model->field (outside of class)
* - $this->field (inside of class) * - $this->field (inside of class)
* *
* @param string $name Name of data to fetch * @param $name
* @return mixed * @return mixed
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
public function __get(string $name) public function __get($name)
{ {
$this->checkValid(); $this->checkValid();

View file

@ -331,7 +331,7 @@ abstract class BaseModule implements ICanHandleRequests
* Actually, important actions should not be triggered by Links / GET-Requests at all, but sometimes they still are, * Actually, important actions should not be triggered by Links / GET-Requests at all, but sometimes they still are,
* so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types). * so this mechanism brings in some damage control (the attacker would be able to forge a request to a form of this type, but not to forms of other types).
*/ */
public static function getFormSecurityToken(string $typename = '') public static function getFormSecurityToken($typename = '')
{ {
$user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']); $user = User::getById(DI::app()->getLoggedInUserId(), ['guid', 'prvkey']);
$timestamp = time(); $timestamp = time();
@ -340,14 +340,7 @@ abstract class BaseModule implements ICanHandleRequests
return $timestamp . '.' . $sec_hash; return $timestamp . '.' . $sec_hash;
} }
/** public static function checkFormSecurityToken($typename = '', $formname = 'form_security_token')
* Checks if form's security (CSRF) token is valid.
*
* @param string $typename ???
* @param string $formname Name of form/field (???)
* @return bool Whether it is valid
*/
public static function checkFormSecurityToken(string $typename = '', string $formname = 'form_security_token'): bool
{ {
$hash = null; $hash = null;
@ -379,12 +372,12 @@ abstract class BaseModule implements ICanHandleRequests
return ($sec_hash == $x[1]); return ($sec_hash == $x[1]);
} }
public static function getFormSecurityStandardErrorMessage(): string public static function getFormSecurityStandardErrorMessage()
{ {
return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL; return DI::l10n()->t("The form security token was not correct. This probably happened because the form has been opened for too long \x28>3 hours\x29 before submitting it.") . EOL;
} }
public static function checkFormSecurityTokenRedirectOnError(string $err_redirect, string $typename = '', string $formname = 'form_security_token') public static function checkFormSecurityTokenRedirectOnError($err_redirect, $typename = '', $formname = 'form_security_token')
{ {
if (!self::checkFormSecurityToken($typename, $formname)) { if (!self::checkFormSecurityToken($typename, $formname)) {
Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename); Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);
@ -394,7 +387,7 @@ abstract class BaseModule implements ICanHandleRequests
} }
} }
public static function checkFormSecurityTokenForbiddenOnError(string $typename = '', string $formname = 'form_security_token') public static function checkFormSecurityTokenForbiddenOnError($typename = '', $formname = 'form_security_token')
{ {
if (!self::checkFormSecurityToken($typename, $formname)) { if (!self::checkFormSecurityToken($typename, $formname)) {
Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename); Logger::notice('checkFormSecurityToken failed: user ' . DI::app()->getLoggedInUserNickname() . ' - form element ' . $typename);

View file

@ -32,6 +32,7 @@ use Friendica\Util\HTTPSignature;
use Friendica\Util\Images; use Friendica\Util\Images;
use Friendica\Util\Network; use Friendica\Util\Network;
use Friendica\Util\Proxy; use Friendica\Util\Proxy;
use Friendica\Util\Strings;
/** /**
* functions for handling contact avatar caching * functions for handling contact avatar caching
@ -123,7 +124,7 @@ class Avatar
return $fields; return $fields;
} }
private static function getFilename(string $url): string private static function getFilename(string $url)
{ {
$guid = Item::guidFromUri($url, parse_url($url, PHP_URL_HOST)); $guid = Item::guidFromUri($url, parse_url($url, PHP_URL_HOST));
@ -138,19 +139,21 @@ class Avatar
return ''; return '';
} }
$path = $filename . $size . '.' . $image->getExt(); $path = self::BASE_PATH . $filename . $size . '.' . $image->getExt();
$basepath = self::basePath(); $filepath = DI::basePath() . $path;
if (empty($basepath)) {
return '';
}
$filepath = $basepath . $path; $dirpath = DI::basePath() . self::BASE_PATH;
$dirpath = $basepath;
DI::profiler()->startRecording('file'); DI::profiler()->startRecording('file');
if (!file_exists($dirpath)) {
if (!mkdir($dirpath, 0775)) {
Logger::warning('Base directory could not be created', ['directory' => $dirpath]);
return '';
}
}
// Fetch the permission and group ownership of the "avatar" path and apply to all files // Fetch the permission and group ownership of the "avatar" path and apply to all files
$dir_perm = fileperms($dirpath) & 0777; $dir_perm = fileperms($dirpath) & 0777;
$file_perm = fileperms($dirpath) & 0666; $file_perm = fileperms($dirpath) & 0666;
@ -195,7 +198,7 @@ class Avatar
return ''; return '';
} }
return self::baseUrl() . $path . '?ts=' . $timestamp; return DI::baseUrl() . $path . '?ts=' . $timestamp;
} }
/** /**
@ -218,17 +221,16 @@ class Avatar
private static function getCacheFile(string $avatar): string private static function getCacheFile(string $avatar): string
{ {
$parts = parse_url($avatar); $parts = parse_url($avatar);
if (empty($parts['host']) || ($parts['host'] != parse_url(self::baseUrl(), PHP_URL_HOST))) { if (empty($parts['host']) || ($parts['host'] != DI::baseUrl()->getHostname())) {
return ''; return '';
} }
$avatarpath = parse_url(self::baseUrl(), PHP_URL_PATH); $pos = strpos($parts['path'], DI::baseUrl()->getUrlPath() . self::BASE_PATH);
$pos = strpos($parts['path'], $avatarpath);
if ($pos !== 0) { if ($pos !== 0) {
return ''; return '';
} }
$filename = self::basePath() . substr($parts['path'], strlen($avatarpath)); $filename = DI::basePath() . $parts['path'];
DI::profiler()->startRecording('file'); DI::profiler()->startRecording('file');
$exists = file_exists($filename); $exists = file_exists($filename);
@ -267,47 +269,4 @@ class Avatar
Logger::debug('Unlink avatar', ['avatar' => $avatar]); Logger::debug('Unlink avatar', ['avatar' => $avatar]);
} }
} }
/**
* Fetch the avatar base path
*
* @return string
*/
private static function basePath(): string
{
$basepath = DI::config()->get('system', 'avatar_cache_path');
if (empty($basepath)) {
$basepath = DI::basePath() . self::BASE_PATH;
}
$basepath = rtrim($basepath, '/') . '/';
if (!file_exists($basepath)) {
// We only automatically create the folder when it is in the web root
if (strpos($basepath, DI::basePath()) !== 0) {
Logger::warning('Base directory does not exist', ['directory' => $basepath]);
return '';
}
if (!mkdir($basepath, 0775)) {
Logger::warning('Base directory could not be created', ['directory' => $basepath]);
return '';
}
}
return $basepath;
}
/**
* Fetch the avatar base url
*
* @return string
*/
private static function baseUrl(): string
{
$baseurl = DI::config()->get('system', 'avatar_cache_url');
if (!empty($baseurl)) {
return rtrim($baseurl, '/') . '/';
}
return DI::baseUrl() . self::BASE_PATH;
}
} }

View file

@ -49,7 +49,7 @@ class BoundariesPager extends Pager
* @param string $last_item_id The id† of the last item in the displayed item list * @param string $last_item_id The id† of the last item in the displayed item list
* @param integer $itemsPerPage An optional number of items per page to override the default value * @param integer $itemsPerPage An optional number of items per page to override the default value
*/ */
public function __construct(L10n $l10n, string $queryString, string $first_item_id = null, string $last_item_id = null, int $itemsPerPage = 50) public function __construct(L10n $l10n, $queryString, $first_item_id = null, $last_item_id = null, $itemsPerPage = 50)
{ {
parent::__construct($l10n, $queryString, $itemsPerPage); parent::__construct($l10n, $queryString, $itemsPerPage);
@ -102,7 +102,7 @@ class BoundariesPager extends Pager
* @return string HTML string of the pager * @return string HTML string of the pager
* @throws \Exception * @throws \Exception
*/ */
public function renderMinimal(int $itemCount): string public function renderMinimal(int $itemCount)
{ {
$displayedItemCount = max(0, intval($itemCount)); $displayedItemCount = max(0, intval($itemCount));

View file

@ -41,7 +41,7 @@ class ContactSelector
* @param boolean $disabled optional, default false * @param boolean $disabled optional, default false
* @return string * @return string
*/ */
public static function pollInterval(string $current, bool $disabled = false): string public static function pollInterval($current, $disabled = false)
{ {
$dis = (($disabled) ? ' disabled="disabled" ' : ''); $dis = (($disabled) ? ' disabled="disabled" ' : '');
$o = ''; $o = '';
@ -84,7 +84,7 @@ class ContactSelector
* @return string Server URL * @return string Server URL
* @throws \Exception * @throws \Exception
*/ */
private static function getServerURLForProfile(string $profile): string private static function getServerURLForProfile($profile)
{ {
if (!empty(self::$server_url[$profile])) { if (!empty(self::$server_url[$profile])) {
return self::$server_url[$profile]; return self::$server_url[$profile];
@ -111,16 +111,13 @@ class ContactSelector
} }
/** /**
* Determines network name
*
* @param string $network network of the contact * @param string $network network of the contact
* @param string $profile optional, default empty * @param string $profile optional, default empty
* @param string $protocol (Optional) Protocol that is used for the transmission * @param string $protocol (Optional) Protocol that is used for the transmission
* @param int $gsid Server id
* @return string * @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function networkToName(string $network, string $profile = '', string $protocol = '', int $gsid = null): string public static function networkToName($network, $profile = '', $protocol = '', $gsid = 0)
{ {
$nets = [ $nets = [
Protocol::DFRN => DI::l10n()->t('DFRN'), Protocol::DFRN => DI::l10n()->t('DFRN'),
@ -182,15 +179,12 @@ class ContactSelector
} }
/** /**
* Determines network's icon name
*
* @param string $network network * @param string $network network
* @param string $profile optional, default empty * @param string $profile optional, default empty
* @param int $gsid Server id * @return string
* @return string Name for network icon
* @throws \Exception * @throws \Exception
*/ */
public static function networkToIcon(string $network, string $profile = "", int $gsid = null): string public static function networkToIcon($network, $profile = "", $gsid = 0)
{ {
$nets = [ $nets = [
Protocol::DFRN => 'friendica', Protocol::DFRN => 'friendica',

View file

@ -154,7 +154,7 @@ class Conversation
} }
// Skip when the causer of the parent is the same as the author of the announce // Skip when the causer of the parent is the same as the author of the announce
if (($verb == Activity::ANNOUNCE) && !empty($thread_parent['causer-id']) && ($thread_parent['causer-id'] == $activity['author-id'])) { if (($verb == Activity::ANNOUNCE) && !empty($thread_parent['causer-id'] && ($thread_parent['causer-id'] == $activity['author-id']))) {
continue; continue;
} }
@ -189,7 +189,7 @@ class Conversation
* @return string formatted text * @return string formatted text
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public function formatActivity(array $links, string $verb, int $id): string public function formatActivity(array $links, $verb, $id)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
$o = ''; $o = '';
@ -275,7 +275,7 @@ class Conversation
return $o; return $o;
} }
public function statusEditor(array $x = [], int $notes_cid = 0, bool $popup = false): string public function statusEditor(array $x = [], $notes_cid = 0, $popup = false)
{ {
$user = User::getById($this->app->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']); $user = User::getById($this->app->getLoggedInUserId(), ['uid', 'nickname', 'allow_location', 'default-location']);
if (empty($user['uid'])) { if (empty($user['uid'])) {
@ -414,8 +414,8 @@ class Conversation
* figures out how to determine page owner and other contextual items * figures out how to determine page owner and other contextual items
* that are based on unique features of the calling module. * that are based on unique features of the calling module.
* @param array $items * @param array $items
* @param string $mode * @param $mode
* @param $update @TODO Which type? * @param $update
* @param bool $preview * @param bool $preview
* @param string $order * @param string $order
* @param int $uid * @param int $uid
@ -423,7 +423,7 @@ class Conversation
* @throws ImagickException * @throws ImagickException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public function create(array $items, string $mode, $update, bool $preview = false, string $order = 'commented', int $uid = 0): string public function create(array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
@ -784,7 +784,7 @@ class Conversation
return $o; return $o;
} }
private function getBlocklist(): array private function getBlocklist()
{ {
if (!local_user()) { if (!local_user()) {
return []; return [];
@ -816,7 +816,7 @@ class Conversation
* *
* @return array items with parents and comments * @return array items with parents and comments
*/ */
private function addRowInformation(array $row, array $activity, array $thr_parent): array private function addRowInformation(array $row, array $activity, array $thr_parent)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
@ -911,7 +911,7 @@ class Conversation
* @return array items with parents and comments * @return array items with parents and comments
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private function addChildren(array $parents, bool $block_authors, string $order, int $uid, string $mode): array private function addChildren(array $parents, bool $block_authors, string $order, int $uid, string $mode)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
if (count($parents) > 1) { if (count($parents) > 1) {
@ -1005,7 +1005,7 @@ class Conversation
* @param bool $recursive * @param bool $recursive
* @return array * @return array
*/ */
private function getItemChildren(array &$item_list, array $parent, bool $recursive = true): array private function getItemChildren(array &$item_list, array $parent, $recursive = true)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
$children = []; $children = [];
@ -1040,7 +1040,7 @@ class Conversation
* @param array $items * @param array $items
* @return array * @return array
*/ */
private function sortItemChildren(array $items): array private function sortItemChildren(array $items)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
$result = $items; $result = $items;
@ -1086,7 +1086,7 @@ class Conversation
* @param array $parent A tree-like array of items * @param array $parent A tree-like array of items
* @return array * @return array
*/ */
private function smartFlattenConversation(array $parent): array private function smartFlattenConversation(array $parent)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
if (!isset($parent['children']) || count($parent['children']) == 0) { if (!isset($parent['children']) || count($parent['children']) == 0) {
@ -1142,7 +1142,7 @@ class Conversation
* @return array * @return array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private function convSort(array $item_list, string $order): array private function convSort(array $item_list, $order)
{ {
$this->profiler->startRecording('rendering'); $this->profiler->startRecording('rendering');
$parents = []; $parents = [];
@ -1222,7 +1222,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrFeaturedReceived(array $a, array $b): int private function sortThrFeaturedReceived(array $a, array $b)
{ {
if ($b['featured'] && !$a['featured']) { if ($b['featured'] && !$a['featured']) {
return 1; return 1;
@ -1240,7 +1240,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrFeaturedCommented(array $a, array $b): int private function sortThrFeaturedCommented(array $a, array $b)
{ {
if ($b['featured'] && !$a['featured']) { if ($b['featured'] && !$a['featured']) {
return 1; return 1;
@ -1258,7 +1258,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrReceived(array $a, array $b): int private function sortThrReceived(array $a, array $b)
{ {
return strcmp($b['received'], $a['received']); return strcmp($b['received'], $a['received']);
} }
@ -1270,7 +1270,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrReceivedRev(array $a, array $b): int private function sortThrReceivedRev(array $a, array $b)
{ {
return strcmp($a['received'], $b['received']); return strcmp($a['received'], $b['received']);
} }
@ -1282,7 +1282,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrCommented(array $a, array $b): int private function sortThrCommented(array $a, array $b)
{ {
return strcmp($b['commented'], $a['commented']); return strcmp($b['commented'], $a['commented']);
} }
@ -1294,7 +1294,7 @@ class Conversation
* @param array $b * @param array $b
* @return int * @return int
*/ */
private function sortThrCreated(array $a, array $b): int private function sortThrCreated(array $a, array $b)
{ {
return strcmp($b['created'], $a['created']); return strcmp($b['created'], $a['created']);
} }

View file

@ -61,7 +61,7 @@ class HTML
* inner value from an attribute value and disregard the tag children. * inner value from an attribute value and disregard the tag children.
* @return bool Whether a replacement was done * @return bool Whether a replacement was done
*/ */
private static function tagToBBCodeSub(DOMDocument $doc, string $tag, array $attributes, string $startbb, string $endbb, bool $ignoreChildren = false): bool private static function tagToBBCodeSub(DOMDocument $doc, string $tag, array $attributes, string $startbb, string $endbb, bool $ignoreChildren = false)
{ {
$savestart = str_replace('$', '\x01', $startbb); $savestart = str_replace('$', '\x01', $startbb);
$replace = false; $replace = false;
@ -141,16 +141,8 @@ class HTML
* @return string * @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function toBBCode(string $message, string $basepath = ''): string public static function toBBCode($message, $basepath = '')
{ {
/*
* Check if message is empty to prevent a lot code below being executed
* for just an empty message.
*/
if (empty($message)) {
return '';
}
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
$message = str_replace("\r", "", $message); $message = str_replace("\r", "", $message);
@ -417,7 +409,7 @@ class HTML
* *
* @return string The expanded URL * @return string The expanded URL
*/ */
private static function qualifyURLsSub(array $matches, string $basepath): string private static function qualifyURLsSub($matches, $basepath)
{ {
$base = parse_url($basepath); $base = parse_url($basepath);
unset($base['query']); unset($base['query']);
@ -444,7 +436,7 @@ class HTML
* *
* @return string Body with expanded URLs * @return string Body with expanded URLs
*/ */
private static function qualifyURLs(string $body, string $basepath): string private static function qualifyURLs($body, $basepath)
{ {
$URLSearchString = "^\[\]"; $URLSearchString = "^\[\]";
@ -470,7 +462,7 @@ class HTML
return $body; return $body;
} }
private static function breakLines(string $line, int $level, int $wraplength = 75): string private static function breakLines($line, $level, $wraplength = 75)
{ {
if ($wraplength == 0) { if ($wraplength == 0) {
$wraplength = 2000000; $wraplength = 2000000;
@ -511,7 +503,7 @@ class HTML
return implode("\n", $newlines); return implode("\n", $newlines);
} }
private static function quoteLevel(string $message, int $wraplength = 75): string private static function quoteLevel($message, $wraplength = 75)
{ {
$lines = explode("\n", $message); $lines = explode("\n", $message);
@ -547,7 +539,7 @@ class HTML
return implode("\n", $newlines); return implode("\n", $newlines);
} }
private static function collectURLs(string $message): array private static function collectURLs($message)
{ {
$pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is'; $pattern = '/<a.*?href="(.*?)".*?>(.*?)<\/a>/is';
preg_match_all($pattern, $message, $result, PREG_SET_ORDER); preg_match_all($pattern, $message, $result, PREG_SET_ORDER);
@ -593,7 +585,7 @@ class HTML
* @param bool $compact True: Completely strips image tags; False: Keeps image URLs * @param bool $compact True: Completely strips image tags; False: Keeps image URLs
* @return string * @return string
*/ */
public static function toPlaintext(string $html, int $wraplength = 75, bool $compact = false): string public static function toPlaintext(string $html, $wraplength = 75, $compact = false)
{ {
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
$message = str_replace("\r", "", $html); $message = str_replace("\r", "", $html);
@ -713,7 +705,7 @@ class HTML
* @param string $html * @param string $html
* @return string * @return string
*/ */
public static function toMarkdown(string $html): string public static function toMarkdown($html)
{ {
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
$converter = new HtmlConverter(['hard_break' => true]); $converter = new HtmlConverter(['hard_break' => true]);
@ -729,7 +721,7 @@ class HTML
* @param string $s * @param string $s
* @return string * @return string
*/ */
public static function toBBCodeVideo(string $s): string public static function toBBCodeVideo($s)
{ {
$s = preg_replace( $s = preg_replace(
'#<object[^>]+>(.*?)https?://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)</object>#ism', '#<object[^>]+>(.*?)https?://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)</object>#ism',
@ -759,7 +751,7 @@ class HTML
* @param string $base base url * @param string $base base url
* @return string * @return string
*/ */
public static function relToAbs(string $text, string $base): string public static function relToAbs($text, $base)
{ {
if (empty($base)) { if (empty($base)) {
return $text; return $text;
@ -798,7 +790,7 @@ class HTML
* @return string html for loader * @return string html for loader
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function scrollLoader(): string public static function scrollLoader()
{ {
$tpl = Renderer::getMarkupTemplate("scroll_loader.tpl"); $tpl = Renderer::getMarkupTemplate("scroll_loader.tpl");
return Renderer::replaceMacros($tpl, [ return Renderer::replaceMacros($tpl, [
@ -827,7 +819,7 @@ class HTML
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function micropro(array $contact, bool $redirect = false, string $class = '', bool $textmode = false): string public static function micropro($contact, $redirect = false, $class = '', $textmode = false)
{ {
// Use the contact URL if no address is available // Use the contact URL if no address is available
if (empty($contact['addr'])) { if (empty($contact['addr'])) {
@ -867,12 +859,13 @@ class HTML
* *
* @param string $s Search query. * @param string $s Search query.
* @param string $id HTML id * @param string $id HTML id
* @param string $url Search url.
* @param bool $aside Display the search widgit aside. * @param bool $aside Display the search widgit aside.
* *
* @return string Formatted HTML. * @return string Formatted HTML.
* @throws \Exception * @throws \Exception
*/ */
public static function search(string $s, string $id = 'search-box', bool $aside = true): string public static function search($s, $id = 'search-box', $aside = true)
{ {
$mode = 'text'; $mode = 'text';
@ -913,7 +906,7 @@ class HTML
* @param string $s * @param string $s
* @return string * @return string
*/ */
public static function toLink(string $s): string public static function toLink($s)
{ {
$s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="_blank" rel="noopener noreferrer">$1</a>', $s); $s = preg_replace("/(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\'\%\$\!\+]*)/", ' <a href="$1" target="_blank" rel="noopener noreferrer">$1</a>', $s);
$s = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism", '<$1$2=$3&$4>', $s); $s = preg_replace("/\<(.*?)(src|href)=(.*?)\&amp\;(.*?)\>/ism", '<$1$2=$3&$4>', $s);
@ -930,7 +923,7 @@ class HTML
* @return string * @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function applyContentFilter(string $html, array $reasons): string public static function applyContentFilter($html, array $reasons)
{ {
if (count($reasons)) { if (count($reasons)) {
$tpl = Renderer::getMarkupTemplate('wall/content_filter.tpl'); $tpl = Renderer::getMarkupTemplate('wall/content_filter.tpl');
@ -950,7 +943,7 @@ class HTML
* @param string $s * @param string $s
* @return string * @return string
*/ */
public static function unamp(string $s): string public static function unamp($s)
{ {
return str_replace('&amp;', '&', $s); return str_replace('&amp;', '&', $s);
} }

View file

@ -45,7 +45,7 @@ class Widget
* @return string * @return string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function follow(string $value = ''): string public static function follow($value = "")
{ {
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), array( return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/follow.tpl'), array(
'$connect' => DI::l10n()->t('Add New Contact'), '$connect' => DI::l10n()->t('Add New Contact'),
@ -58,10 +58,8 @@ class Widget
/** /**
* Return Find People widget * Return Find People widget
*
* @return string HTML code respresenting "People Widget"
*/ */
public static function findPeople(): string public static function findPeople()
{ {
$global_dir = Search::getGlobalDirectory(); $global_dir = Search::getGlobalDirectory();
@ -99,7 +97,7 @@ class Widget
* *
* @return array Unsupported networks * @return array Unsupported networks
*/ */
public static function unavailableNetworks(): array public static function unavailableNetworks()
{ {
// Always hide content from these networks // Always hide content from these networks
$networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET, Protocol::ZOT]; $networks = [Protocol::PHANTOM, Protocol::FACEBOOK, Protocol::APPNET, Protocol::ZOT];
@ -156,7 +154,7 @@ class Widget
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
private static function filter(string $type, string $title, string $desc, string $all, string $baseUrl, array $options, string $selected = null): string private static function filter($type, $title, $desc, $all, $baseUrl, array $options, $selected = null)
{ {
$queryString = parse_url($baseUrl, PHP_URL_QUERY); $queryString = parse_url($baseUrl, PHP_URL_QUERY);
$queryArray = []; $queryArray = [];
@ -193,7 +191,7 @@ class Widget
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
public static function groups(string $baseurl, string $selected = ''): string public static function groups($baseurl, $selected = '')
{ {
if (!local_user()) { if (!local_user()) {
return ''; return '';

View file

@ -656,7 +656,7 @@ class Installer
* @return bool true if the check was successful, otherwise false * @return bool true if the check was successful, otherwise false
* @throws Exception * @throws Exception
*/ */
public function checkDB(Database $dba): bool public function checkDB(Database $dba)
{ {
$dba->reconnect(); $dba->reconnect();

View file

@ -60,7 +60,7 @@ class Worker
* @return void * @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function processQueue(bool $run_cron, Process $process) public static function processQueue($run_cron, Process $process)
{ {
self::$up_start = microtime(true); self::$up_start = microtime(true);
@ -169,7 +169,7 @@ class Worker
* *
* @return boolean * @return boolean
*/ */
public static function isReady(): bool public static function isReady()
{ {
// Count active workers and compare them with a maximum value that depends on the load // Count active workers and compare them with a maximum value that depends on the load
if (self::tooMuchWorkers()) { if (self::tooMuchWorkers()) {
@ -204,7 +204,7 @@ class Worker
* @return boolean Returns "true" if tasks are existing * @return boolean Returns "true" if tasks are existing
* @throws \Exception * @throws \Exception
*/ */
public static function entriesExists(): bool public static function entriesExists()
{ {
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
$exists = DBA::exists('workerqueue', ["NOT `done` AND `pid` = 0 AND `next_try` < ?", DateTimeFormat::utcNow()]); $exists = DBA::exists('workerqueue', ["NOT `done` AND `pid` = 0 AND `next_try` < ?", DateTimeFormat::utcNow()]);
@ -218,7 +218,7 @@ class Worker
* @return integer Number of deferred entries in the worker queue * @return integer Number of deferred entries in the worker queue
* @throws \Exception * @throws \Exception
*/ */
private static function deferredEntries(): int private static function deferredEntries()
{ {
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
$count = DBA::count('workerqueue', ["NOT `done` AND `pid` = 0 AND `retrial` > ?", 0]); $count = DBA::count('workerqueue', ["NOT `done` AND `pid` = 0 AND `retrial` > ?", 0]);
@ -233,7 +233,7 @@ class Worker
* @return integer Number of non executed entries in the worker queue * @return integer Number of non executed entries in the worker queue
* @throws \Exception * @throws \Exception
*/ */
private static function totalEntries(): int private static function totalEntries()
{ {
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
$count = DBA::count('workerqueue', ['done' => false, 'pid' => 0]); $count = DBA::count('workerqueue', ['done' => false, 'pid' => 0]);
@ -248,7 +248,7 @@ class Worker
* @return integer Number of active worker processes * @return integer Number of active worker processes
* @throws \Exception * @throws \Exception
*/ */
private static function highestPriority(): int private static function highestPriority()
{ {
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
$condition = ["`pid` = 0 AND NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()]; $condition = ["`pid` = 0 AND NOT `done` AND `next_try` < ?", DateTimeFormat::utcNow()];
@ -269,7 +269,7 @@ class Worker
* @return integer Is there a process running with that priority? * @return integer Is there a process running with that priority?
* @throws \Exception * @throws \Exception
*/ */
private static function processWithPriorityActive(int $priority): int private static function processWithPriorityActive($priority)
{ {
$condition = ["`priority` <= ? AND `pid` != 0 AND NOT `done`", $priority]; $condition = ["`priority` <= ? AND `pid` != 0 AND NOT `done`", $priority];
return DBA::exists('workerqueue', $condition); return DBA::exists('workerqueue', $condition);
@ -281,7 +281,7 @@ class Worker
* @param mixed $file * @param mixed $file
* @return bool * @return bool
*/ */
private static function validateInclude(&$file): bool private static function validateInclude(&$file)
{ {
$orig_file = $file; $orig_file = $file;
@ -321,7 +321,7 @@ class Worker
* @return boolean "true" if further processing should be stopped * @return boolean "true" if further processing should be stopped
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function execute(array $queue): bool public static function execute($queue)
{ {
$mypid = getmypid(); $mypid = getmypid();
@ -454,7 +454,7 @@ class Worker
* @return void * @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function execFunction(array $queue, string $funcname, array $argv, bool $method_call) private static function execFunction($queue, $funcname, $argv, $method_call)
{ {
$a = DI::app(); $a = DI::app();
@ -543,7 +543,7 @@ class Worker
* @return bool Are more than 3/4 of the maximum connections used? * @return bool Are more than 3/4 of the maximum connections used?
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function maxConnectionsReached(): bool private static function maxConnectionsReached()
{ {
// Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself. // Fetch the max value from the config. This is needed when the system cannot detect the correct value by itself.
$max = DI::config()->get("system", "max_connections"); $max = DI::config()->get("system", "max_connections");
@ -627,7 +627,7 @@ class Worker
* @return bool Are there too much workers running? * @return bool Are there too much workers running?
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function tooMuchWorkers(): bool private static function tooMuchWorkers()
{ {
$queues = DI::config()->get("system", "worker_queues", 10); $queues = DI::config()->get("system", "worker_queues", 10);
@ -751,7 +751,7 @@ class Worker
* @return integer Number of active worker processes * @return integer Number of active worker processes
* @throws \Exception * @throws \Exception
*/ */
private static function activeWorkers(): int private static function activeWorkers()
{ {
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
$count = DI::process()->countCommand('Worker.php'); $count = DI::process()->countCommand('Worker.php');
@ -766,7 +766,7 @@ class Worker
* @return array List of worker process ids * @return array List of worker process ids
* @throws \Exception * @throws \Exception
*/ */
private static function getWorkerPIDList(): array private static function getWorkerPIDList()
{ {
$ids = []; $ids = [];
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
@ -787,7 +787,7 @@ class Worker
/** /**
* Returns waiting jobs for the current process id * Returns waiting jobs for the current process id
* *
* @return array|bool waiting workerqueue jobs or FALSE on failture * @return array waiting workerqueue jobs
* @throws \Exception * @throws \Exception
*/ */
private static function getWaitingJobForPID() private static function getWaitingJobForPID()
@ -809,7 +809,7 @@ class Worker
* @return array array with next jobs * @return array array with next jobs
* @throws \Exception * @throws \Exception
*/ */
private static function nextProcess(int $limit): array private static function nextProcess(int $limit)
{ {
$priority = self::nextPriority(); $priority = self::nextPriority();
if (empty($priority)) { if (empty($priority)) {
@ -844,7 +844,7 @@ class Worker
/** /**
* Returns the priority of the next workerqueue job * Returns the priority of the next workerqueue job
* *
* @return string|bool priority or FALSE on failure * @return string priority
* @throws \Exception * @throws \Exception
*/ */
private static function nextPriority() private static function nextPriority()
@ -915,7 +915,7 @@ class Worker
/** /**
* Find and claim the next worker process for us * Find and claim the next worker process for us
* *
* @return void * @return boolean Have we found something?
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function findWorkerProcesses() private static function findWorkerProcesses()
@ -993,7 +993,7 @@ class Worker
* @return array worker processes * @return array worker processes
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function workerProcess(): array public static function workerProcess()
{ {
// There can already be jobs for us in the queue. // There can already be jobs for us in the queue.
$waiting = self::getWaitingJobForPID(); $waiting = self::getWaitingJobForPID();
@ -1003,7 +1003,7 @@ class Worker
$stamp = (float)microtime(true); $stamp = (float)microtime(true);
if (!DI::lock()->acquire(self::LOCK_PROCESS)) { if (!DI::lock()->acquire(self::LOCK_PROCESS)) {
return []; return false;
} }
self::$lock_duration += (microtime(true) - $stamp); self::$lock_duration += (microtime(true) - $stamp);
@ -1011,9 +1011,7 @@ class Worker
DI::lock()->release(self::LOCK_PROCESS); DI::lock()->release(self::LOCK_PROCESS);
// Prevents "Return value of Friendica\Core\Worker::workerProcess() must be of the type array, bool returned" return self::getWaitingJobForPID();
$process = self::getWaitingJobForPID();
return (is_array($process) ? $process : []);
} }
/** /**
@ -1099,7 +1097,7 @@ class Worker
* @return void * @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function spawnWorker(bool $do_cron = false) public static function spawnWorker($do_cron = false)
{ {
if (Worker\Daemon::isMode() && DI::config()->get('system', 'worker_fork')) { if (Worker\Daemon::isMode() && DI::config()->get('system', 'worker_fork')) {
self::forkProcess($do_cron); self::forkProcess($do_cron);
@ -1233,7 +1231,7 @@ class Worker
return $added; return $added;
} }
public static function countWorkersByCommand(string $command): int public static function countWorkersByCommand(string $command)
{ {
return DBA::count('workerqueue', ['done' => false, 'pid' => 0, 'command' => $command]); return DBA::count('workerqueue', ['done' => false, 'pid' => 0, 'command' => $command]);
} }
@ -1246,7 +1244,7 @@ class Worker
* @param integer $max_level maximum retrial level * @param integer $max_level maximum retrial level
* @return integer the next retrial level value * @return integer the next retrial level value
*/ */
private static function getNextRetrial(array $queue, int $max_level): int private static function getNextRetrial($queue, $max_level)
{ {
$created = strtotime($queue['created']); $created = strtotime($queue['created']);
$retrial_time = time() - $created; $retrial_time = time() - $created;
@ -1316,10 +1314,9 @@ class Worker
/** /**
* Check if the system is inside the defined maintenance window * Check if the system is inside the defined maintenance window
* *
* @param bool $check_last_execution Whether check last execution
* @return boolean * @return boolean
*/ */
public static function isInMaintenanceWindow(bool $check_last_execution = false): bool public static function isInMaintenanceWindow(bool $check_last_execution = false)
{ {
// Calculate the seconds of the start end end of the maintenance window // Calculate the seconds of the start end end of the maintenance window
$start = strtotime(DI::config()->get('system', 'maintenance_start')) % 86400; $start = strtotime(DI::config()->get('system', 'maintenance_start')) % 86400;

View file

@ -427,7 +427,7 @@ class DBA
* @return boolean was the update successfull? * @return boolean was the update successfull?
* @throws \Exception * @throws \Exception
*/ */
public static function update($table, array $fields, array $condition, $old_fields = [], array $params = []) public static function update($table, $fields, $condition, $old_fields = [], $params = [])
{ {
return DI::dba()->update($table, $fields, $condition, $old_fields, $params); return DI::dba()->update($table, $fields, $condition, $old_fields, $params);
} }
@ -443,7 +443,7 @@ class DBA
* @throws \Exception * @throws \Exception
* @see self::select * @see self::select
*/ */
public static function selectFirst($table, array $fields = [], array $condition = [], array $params = []) public static function selectFirst($table, array $fields = [], array $condition = [], $params = [])
{ {
return DI::dba()->selectFirst($table, $fields, $condition, $params); return DI::dba()->selectFirst($table, $fields, $condition, $params);
} }
@ -512,7 +512,7 @@ class DBA
* $count = DBA::count($table, $condition); * $count = DBA::count($table, $condition);
* @throws \Exception * @throws \Exception
*/ */
public static function count($table, array $condition = [], array $params = []): int public static function count($table, array $condition = [], array $params = [])
{ {
return DI::dba()->count($table, $condition, $params); return DI::dba()->count($table, $condition, $params);
} }
@ -771,7 +771,7 @@ class DBA
* *
* @return array Data array * @return array Data array
*/ */
public static function toArray($stmt, $do_close = true, int $count = 0): array public static function toArray($stmt, $do_close = true, int $count = 0)
{ {
return DI::dba()->toArray($stmt, $do_close, $count); return DI::dba()->toArray($stmt, $do_close, $count);
} }
@ -783,7 +783,7 @@ class DBA
* @param array $fields * @param array $fields
* @return array casted fields * @return array casted fields
*/ */
public static function castFields(string $table, array $fields): array public static function castFields(string $table, array $fields)
{ {
return DI::dba()->castFields($table, $fields); return DI::dba()->castFields($table, $fields);
} }
@ -793,7 +793,7 @@ class DBA
* *
* @return string Error number (0 if no error) * @return string Error number (0 if no error)
*/ */
public static function errorNo(): int public static function errorNo()
{ {
return DI::dba()->errorNo(); return DI::dba()->errorNo();
} }
@ -803,7 +803,7 @@ class DBA
* *
* @return string Error message ('' if no error) * @return string Error message ('' if no error)
*/ */
public static function errorMessage(): string public static function errorMessage()
{ {
return DI::dba()->errorMessage(); return DI::dba()->errorMessage();
} }
@ -814,7 +814,7 @@ class DBA
* @param object $stmt statement object * @param object $stmt statement object
* @return boolean was the close successful? * @return boolean was the close successful?
*/ */
public static function close($stmt): bool public static function close($stmt)
{ {
return DI::dba()->close($stmt); return DI::dba()->close($stmt);
} }
@ -827,7 +827,7 @@ class DBA
* 'amount' => Number of concurrent database processes * 'amount' => Number of concurrent database processes
* @throws \Exception * @throws \Exception
*/ */
public static function processlist(): array public static function processlist()
{ {
return DI::dba()->processlist(); return DI::dba()->processlist();
} }

View file

@ -150,9 +150,10 @@ class DBStructure
* Print out database error messages * Print out database error messages
* *
* @param string $message Message to be added to the error message * @param string $message Message to be added to the error message
*
* @return string Error message * @return string Error message
*/ */
private static function printUpdateError(string $message): string private static function printUpdateError($message)
{ {
echo DI::l10n()->t("\nError %d occurred during database update:\n%s\n", echo DI::l10n()->t("\nError %d occurred during database update:\n%s\n",
DBA::errorNo(), DBA::errorMessage()); DBA::errorNo(), DBA::errorMessage());
@ -163,7 +164,7 @@ class DBStructure
public static function writeStructure() public static function writeStructure()
{ {
$tables = []; $tables = [];
foreach (self::definition('') as $name => $definition) { foreach (self::definition(null) as $name => $definition) {
$indexes = [[ $indexes = [[
'name' => 'Name', 'name' => 'Name',
'fields' => 'Fields', 'fields' => 'Fields',
@ -224,8 +225,8 @@ class DBStructure
$field['default'] = $value['default'] ?? 'NULL'; $field['default'] = $value['default'] ?? 'NULL';
$field['extra'] = $value['extra'] ?? ''; $field['extra'] = $value['extra'] ?? '';
foreach ($field as $fieldName => $fieldvalue) { foreach ($field as $fieldname => $fieldvalue) {
$lengths[$fieldName] = max($lengths[$fieldName] ?? 0, strlen($fieldvalue)); $lengths[$fieldname] = max($lengths[$fieldname] ?? 0, strlen($fieldvalue));
} }
$fields[] = $field; $fields[] = $field;
@ -262,7 +263,7 @@ class DBStructure
file_put_contents($filename, $content); file_put_contents($filename, $content);
} }
public static function printStructure(string $basePath) public static function printStructure($basePath)
{ {
$database = self::definition($basePath, false); $database = self::definition($basePath, false);
@ -287,12 +288,12 @@ class DBStructure
* On first pass, defines DB_UPDATE_VERSION constant. * On first pass, defines DB_UPDATE_VERSION constant.
* *
* @see static/dbstructure.config.php * @see static/dbstructure.config.php
* @param string $basePath The base path of this application
* @param boolean $with_addons_structure Whether to tack on addons additional tables * @param boolean $with_addons_structure Whether to tack on addons additional tables
* @param string $basePath The base path of this application
* @return array * @return array
* @throws Exception * @throws Exception
*/ */
public static function definition(string $basePath, bool $with_addons_structure = true): array public static function definition($basePath, $with_addons_structure = true)
{ {
if (!self::$definition) { if (!self::$definition) {
if (empty($basePath)) { if (empty($basePath)) {
@ -302,7 +303,7 @@ class DBStructure
$filename = $basePath . '/static/dbstructure.config.php'; $filename = $basePath . '/static/dbstructure.config.php';
if (!is_readable($filename)) { if (!is_readable($filename)) {
throw new Exception('Missing database structure config file static/dbstructure.config.php at basePath=' . $basePath); throw new Exception('Missing database structure config file static/dbstructure.config.php');
} }
$definition = require $filename; $definition = require $filename;
@ -326,23 +327,23 @@ class DBStructure
/** /**
* Get field data for the given table * Get field data for the given table
* *
* @param string $table Tavle to load field definitions for * @param string $table
* @param array $data data fields * @param array $data data fields
* @return array fields for the given * @return array fields for the given
*/ */
public static function getFieldsForTable(string $table, array $data = []): array public static function getFieldsForTable(string $table, array $data = [])
{ {
$definition = DBStructure::definition('', false); $definition = DBStructure::definition('', false);
if (empty($definition[$table])) { if (empty($definition[$table])) {
return []; return [];
} }
$fieldNames = array_keys($definition[$table]['fields']); $fieldnames = array_keys($definition[$table]['fields']);
$fields = []; $fields = [];
// Assign all field that are present in the table // Assign all field that are present in the table
foreach ($fieldNames as $field) { foreach ($fieldnames as $field) {
if (isset($data[$field])) { if (isset($data[$field])) {
// Limit the length of varchar, varbinary, char and binrary fields // Limit the length of varchar, varbinary, char and binrary fields
if (is_string($data[$field]) && preg_match("/char\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) { if (is_string($data[$field]) && preg_match("/char\((\d*)\)/", $definition[$table]['fields'][$field]['type'], $result)) {
@ -357,54 +358,45 @@ class DBStructure
return $fields; return $fields;
} }
/** private static function createTable($name, $structure, $verbose, $action)
* Creates given table with structure
*
* @param string $name Name of table
* @param array $structure Structure of table
* @param boolean $verbose Output SQL statements
* @param boolean $action Whether to run the SQL commands
* @return Whether the SQL command ran successful
*/
private static function createTable(string $name, array $structure, bool $verbose, bool $action): bool
{ {
$r = true; $r = true;
$engine = ''; $engine = "";
$comment = ''; $comment = "";
$sql_rows = []; $sql_rows = [];
$primary_keys = []; $primary_keys = [];
$foreign_keys = []; $foreign_keys = [];
foreach ($structure['fields'] as $fieldName => $field) { foreach ($structure["fields"] as $fieldname => $field) {
$sql_rows[] = '`' . DBA::escape($fieldName) . '` ' . self::FieldCommand($field); $sql_rows[] = "`" . DBA::escape($fieldname) . "` " . self::FieldCommand($field);
if (!empty($field['primary'])) { if (!empty($field['primary'])) {
$primary_keys[] = $fieldName; $primary_keys[] = $fieldname;
} }
if (!empty($field['foreign'])) { if (!empty($field['foreign'])) {
$foreign_keys[$fieldName] = $field; $foreign_keys[$fieldname] = $field;
} }
} }
if (!empty($structure['indexes'])) { if (!empty($structure["indexes"])) {
foreach ($structure['indexes'] as $indexName => $fieldNames) { foreach ($structure["indexes"] as $indexname => $fieldnames) {
$sql_index = self::createIndex($indexName, $fieldNames, ''); $sql_index = self::createIndex($indexname, $fieldnames, "");
if (!is_null($sql_index)) { if (!is_null($sql_index)) {
$sql_rows[] = $sql_index; $sql_rows[] = $sql_index;
} }
} }
} }
foreach ($foreign_keys as $fieldName => $parameters) { foreach ($foreign_keys as $fieldname => $parameters) {
$sql_rows[] = self::foreignCommand($name, $fieldName, $parameters); $sql_rows[] = self::foreignCommand($name, $fieldname, $parameters);
} }
if (isset($structure['engine'])) { if (isset($structure["engine"])) {
$engine = ' ENGINE=' . $structure['engine']; $engine = " ENGINE=" . $structure["engine"];
} }
if (isset($structure['comment'])) { if (isset($structure["comment"])) {
$comment = " COMMENT='" . DBA::escape($structure['comment']) . "'"; $comment = " COMMENT='" . DBA::escape($structure["comment"]) . "'";
} }
$sql = implode(",\n\t", $sql_rows); $sql = implode(",\n\t", $sql_rows);
@ -422,77 +414,71 @@ class DBStructure
return $r; return $r;
} }
/** private static function FieldCommand($parameters, $create = true)
* Returns SQL statement for field
*
* @param array $parameters Parameters for SQL statement
* @param boolean $create Whether to include PRIMARY KEY statement (unused)
* @return string SQL statement part
*/
private static function FieldCommand(array $parameters, bool $create = true): string
{ {
$fieldstruct = $parameters['type']; $fieldstruct = $parameters["type"];
if (isset($parameters['Collation'])) { if (isset($parameters["Collation"])) {
$fieldstruct .= ' COLLATE ' . $parameters['Collation']; $fieldstruct .= " COLLATE " . $parameters["Collation"];
} }
if (isset($parameters['not null'])) { if (isset($parameters["not null"])) {
$fieldstruct .= ' NOT NULL'; $fieldstruct .= " NOT NULL";
} }
if (isset($parameters['default'])) { if (isset($parameters["default"])) {
if (strpos(strtolower($parameters['type']), 'int') !== false) { if (strpos(strtolower($parameters["type"]), "int") !== false) {
$fieldstruct .= ' DEFAULT ' . $parameters['default']; $fieldstruct .= " DEFAULT " . $parameters["default"];
} else { } else {
$fieldstruct .= " DEFAULT '" . $parameters['default'] . "'"; $fieldstruct .= " DEFAULT '" . $parameters["default"] . "'";
} }
} }
if (isset($parameters['extra'])) { if (isset($parameters["extra"])) {
$fieldstruct .= ' ' . $parameters['extra']; $fieldstruct .= " " . $parameters["extra"];
} }
if (isset($parameters['comment'])) { if (isset($parameters["comment"])) {
$fieldstruct .= " COMMENT '" . DBA::escape($parameters['comment']) . "'"; $fieldstruct .= " COMMENT '" . DBA::escape($parameters["comment"]) . "'";
} }
/*if (($parameters['primary'] != '') && $create) /*if (($parameters["primary"] != "") && $create)
$fieldstruct .= ' PRIMARY KEY';*/ $fieldstruct .= " PRIMARY KEY";*/
return $fieldstruct; return ($fieldstruct);
} }
private static function createIndex(string $indexName, array $fieldNames, string $method = 'ADD') private static function createIndex($indexname, $fieldnames, $method = "ADD")
{ {
$method = strtoupper(trim($method)); $method = strtoupper(trim($method));
if ($method != "" && $method != "ADD") { if ($method != "" && $method != "ADD") {
throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'");
} }
if (in_array($fieldNames[0], ["UNIQUE", "FULLTEXT"])) { if (in_array($fieldnames[0], ["UNIQUE", "FULLTEXT"])) {
$index_type = array_shift($fieldNames); $index_type = array_shift($fieldnames);
$method .= " " . $index_type; $method .= " " . $index_type;
} }
$names = ""; $names = "";
foreach ($fieldNames as $fieldName) { foreach ($fieldnames as $fieldname) {
if ($names != "") { if ($names != "") {
$names .= ","; $names .= ",";
} }
if (preg_match('|(.+)\((\d+)\)|', $fieldName, $matches)) { if (preg_match('|(.+)\((\d+)\)|', $fieldname, $matches)) {
$names .= "`" . DBA::escape($matches[1]) . "`(" . intval($matches[2]) . ")"; $names .= "`" . DBA::escape($matches[1]) . "`(" . intval($matches[2]) . ")";
} else { } else {
$names .= "`" . DBA::escape($fieldName) . "`"; $names .= "`" . DBA::escape($fieldname) . "`";
} }
} }
if ($indexName == "PRIMARY") { if ($indexname == "PRIMARY") {
return sprintf("%s PRIMARY KEY(%s)", $method, $names); return sprintf("%s PRIMARY KEY(%s)", $method, $names);
} }
return sprintf("%s INDEX `%s` (%s)", $method, DBA::escape($indexName), $names); $sql = sprintf("%s INDEX `%s` (%s)", $method, DBA::escape($indexname), $names);
return ($sql);
} }
/** /**
@ -514,7 +500,7 @@ class DBStructure
* @return string Empty string if the update is successful, error messages otherwise * @return string Empty string if the update is successful, error messages otherwise
* @throws Exception * @throws Exception
*/ */
public static function performUpdate(bool $enable_maintenance_mode = true, bool $verbose = false): string public static function performUpdate(bool $enable_maintenance_mode = true, bool $verbose = false)
{ {
if ($enable_maintenance_mode) { if ($enable_maintenance_mode) {
DI::config()->set('system', 'maintenance', 1); DI::config()->set('system', 'maintenance', 1);
@ -538,7 +524,7 @@ class DBStructure
* @return string Empty string if the update is successful, error messages otherwise * @return string Empty string if the update is successful, error messages otherwise
* @throws Exception * @throws Exception
*/ */
public static function install(string $basePath): string public static function install(string $basePath)
{ {
return self::update($basePath, false, true, true); return self::update($basePath, false, true, true);
} }
@ -555,7 +541,7 @@ class DBStructure
* @return string Empty string if the update is successful, error messages otherwise * @return string Empty string if the update is successful, error messages otherwise
* @throws Exception * @throws Exception
*/ */
private static function update(string $basePath, bool $verbose, bool $action, bool $install = false, array $tables = null, array $definition = null): string private static function update($basePath, $verbose, $action, $install = false, array $tables = null, array $definition = null)
{ {
$in_maintenance_mode = DI::config()->get('system', 'maintenance'); $in_maintenance_mode = DI::config()->get('system', 'maintenance');
@ -620,15 +606,15 @@ class DBStructure
* or the definition differ from current status * or the definition differ from current status
* and index name doesn't start with "local_" * and index name doesn't start with "local_"
*/ */
foreach ($database[$name]["indexes"] as $indexName => $fieldNames) { foreach ($database[$name]["indexes"] as $indexname => $fieldnames) {
$current_index_definition = implode(",", $fieldNames); $current_index_definition = implode(",", $fieldnames);
if (isset($structure["indexes"][$indexName])) { if (isset($structure["indexes"][$indexname])) {
$new_index_definition = implode(",", $structure["indexes"][$indexName]); $new_index_definition = implode(",", $structure["indexes"][$indexname]);
} else { } else {
$new_index_definition = "__NOT_SET__"; $new_index_definition = "__NOT_SET__";
} }
if ($current_index_definition != $new_index_definition && substr($indexName, 0, 6) != 'local_') { if ($current_index_definition != $new_index_definition && substr($indexname, 0, 6) != 'local_') {
$sql2 = self::dropIndex($indexName); $sql2 = self::dropIndex($indexname);
if ($sql3 == "") { if ($sql3 == "") {
$sql3 = "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2; $sql3 = "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2;
} else { } else {
@ -637,9 +623,9 @@ class DBStructure
} }
} }
// Compare the field structure field by field // Compare the field structure field by field
foreach ($structure["fields"] as $fieldName => $parameters) { foreach ($structure["fields"] as $fieldname => $parameters) {
if (!isset($database[$name]["fields"][$fieldName])) { if (!isset($database[$name]["fields"][$fieldname])) {
$sql2 = self::addTableField($fieldName, $parameters); $sql2 = self::addTableField($fieldname, $parameters);
if ($sql3 == "") { if ($sql3 == "") {
$sql3 = "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2; $sql3 = "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2;
} else { } else {
@ -647,7 +633,7 @@ class DBStructure
} }
} else { } else {
// Compare the field definition // Compare the field definition
$field_definition = $database[$name]["fields"][$fieldName]; $field_definition = $database[$name]["fields"][$fieldname];
// Remove the relation data that is used for the referential integrity // Remove the relation data that is used for the referential integrity
unset($parameters['relation']); unset($parameters['relation']);
@ -667,7 +653,7 @@ class DBStructure
$current_field_definition = DBA::cleanQuery(implode(",", $field_definition)); $current_field_definition = DBA::cleanQuery(implode(",", $field_definition));
$new_field_definition = DBA::cleanQuery(implode(",", $parameters)); $new_field_definition = DBA::cleanQuery(implode(",", $parameters));
if ($current_field_definition != $new_field_definition) { if ($current_field_definition != $new_field_definition) {
$sql2 = self::modifyTableField($fieldName, $parameters); $sql2 = self::modifyTableField($fieldname, $parameters);
if ($sql3 == "") { if ($sql3 == "") {
$sql3 = "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2; $sql3 = "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2;
} else { } else {
@ -684,15 +670,15 @@ class DBStructure
* Don't create keys if table is new * Don't create keys if table is new
*/ */
if (!$is_new_table) { if (!$is_new_table) {
foreach ($structure["indexes"] as $indexName => $fieldNames) { foreach ($structure["indexes"] as $indexname => $fieldnames) {
if (isset($database[$name]["indexes"][$indexName])) { if (isset($database[$name]["indexes"][$indexname])) {
$current_index_definition = implode(",", $database[$name]["indexes"][$indexName]); $current_index_definition = implode(",", $database[$name]["indexes"][$indexname]);
} else { } else {
$current_index_definition = "__NOT_SET__"; $current_index_definition = "__NOT_SET__";
} }
$new_index_definition = implode(",", $fieldNames); $new_index_definition = implode(",", $fieldnames);
if ($current_index_definition != $new_index_definition) { if ($current_index_definition != $new_index_definition) {
$sql2 = self::createIndex($indexName, $fieldNames); $sql2 = self::createIndex($indexname, $fieldnames);
if ($sql2 != "") { if ($sql2 != "") {
if ($sql3 == "") { if ($sql3 == "") {
@ -708,17 +694,17 @@ class DBStructure
// Foreign keys // Foreign keys
// Compare the field structure field by field // Compare the field structure field by field
foreach ($structure["fields"] as $fieldName => $parameters) { foreach ($structure["fields"] as $fieldname => $parameters) {
if (empty($parameters['foreign'])) { if (empty($parameters['foreign'])) {
continue; continue;
} }
$constraint = self::getConstraintName($name, $fieldName, $parameters); $constraint = self::getConstraintName($name, $fieldname, $parameters);
unset($existing_foreign_keys[$constraint]); unset($existing_foreign_keys[$constraint]);
if (empty($database[$name]['foreign_keys'][$constraint])) { if (empty($database[$name]['foreign_keys'][$constraint])) {
$sql2 = self::addForeignKey($name, $fieldName, $parameters); $sql2 = self::addForeignKey($name, $fieldname, $parameters);
if ($sql3 == "") { if ($sql3 == "") {
$sql3 = "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2; $sql3 = "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2;
@ -781,9 +767,9 @@ class DBStructure
// Now have a look at the field collations // Now have a look at the field collations
// Compare the field structure field by field // Compare the field structure field by field
foreach ($structure["fields"] as $fieldName => $parameters) { foreach ($structure["fields"] as $fieldname => $parameters) {
// Compare the field definition // Compare the field definition
$field_definition = ($database[$name]["fields"][$fieldName] ?? '') ?: ['Collation' => '']; $field_definition = ($database[$name]["fields"][$fieldname] ?? '') ?: ['Collation' => ''];
// Define the default collation if not given // Define the default collation if not given
if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) { if (!isset($parameters['Collation']) && !empty($field_definition['Collation'])) {
@ -793,7 +779,7 @@ class DBStructure
} }
if ($field_definition['Collation'] != $parameters['Collation']) { if ($field_definition['Collation'] != $parameters['Collation']) {
$sql2 = self::modifyTableField($fieldName, $parameters); $sql2 = self::modifyTableField($fieldname, $parameters);
if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) { if (($sql3 == "") || (substr($sql3, -2, 2) == "; ")) {
$sql3 .= "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2; $sql3 .= "ALTER" . $ignore . " TABLE `" . $name . "` " . $sql2;
} else { } else {
@ -840,13 +826,7 @@ class DBStructure
return $errors; return $errors;
} }
/** private static function tableStructure($table)
* Returns an array with table structure information
*
* @param string $table Name of table
* @return array Table structure information
*/
private static function tableStructure(string $table): array
{ {
// This query doesn't seem to be executable as a prepared statement // This query doesn't seem to be executable as a prepared statement
$indexes = DBA::toArray(DBA::p("SHOW INDEX FROM " . DBA::quoteIdentifier($table))); $indexes = DBA::toArray(DBA::p("SHOW INDEX FROM " . DBA::quoteIdentifier($table)));
@ -929,42 +909,41 @@ class DBStructure
} }
} }
return [ return ["fields" => $fielddata, "indexes" => $indexdata,
'fields' => $fielddata, "foreign_keys" => $foreigndata, "table_status" => $table_status];
'indexes' => $indexdata,
'foreign_keys' => $foreigndata,
'table_status' => $table_status
];
} }
private static function dropIndex(string $indexName): string private static function dropIndex($indexname)
{ {
return sprintf("DROP INDEX `%s`", DBA::escape($indexName)); $sql = sprintf("DROP INDEX `%s`", DBA::escape($indexname));
return ($sql);
} }
private static function addTableField(string $fieldName, array $parameters): string private static function addTableField($fieldname, $parameters)
{ {
return sprintf("ADD `%s` %s", DBA::escape($fieldName), self::FieldCommand($parameters)); $sql = sprintf("ADD `%s` %s", DBA::escape($fieldname), self::FieldCommand($parameters));
return ($sql);
} }
private static function modifyTableField(string $fieldName, array $parameters): string private static function modifyTableField($fieldname, $parameters)
{ {
return sprintf("MODIFY `%s` %s", DBA::escape($fieldName), self::FieldCommand($parameters, false)); $sql = sprintf("MODIFY `%s` %s", DBA::escape($fieldname), self::FieldCommand($parameters, false));
return ($sql);
} }
private static function getConstraintName(string $tableName, string $fieldName, array $parameters): string private static function getConstraintName(string $tablename, string $fieldname, array $parameters)
{ {
$foreign_table = array_keys($parameters['foreign'])[0]; $foreign_table = array_keys($parameters['foreign'])[0];
$foreign_field = array_values($parameters['foreign'])[0]; $foreign_field = array_values($parameters['foreign'])[0];
return $tableName . '-' . $fieldName. '-' . $foreign_table. '-' . $foreign_field; return $tablename . "-" . $fieldname. "-" . $foreign_table. "-" . $foreign_field;
} }
private static function foreignCommand(string $tableName, string $fieldName, array $parameters) { private static function foreignCommand(string $tablename, string $fieldname, array $parameters) {
$foreign_table = array_keys($parameters['foreign'])[0]; $foreign_table = array_keys($parameters['foreign'])[0];
$foreign_field = array_values($parameters['foreign'])[0]; $foreign_field = array_values($parameters['foreign'])[0];
$sql = "FOREIGN KEY (`" . $fieldName . "`) REFERENCES `" . $foreign_table . "` (`" . $foreign_field . "`)"; $sql = "FOREIGN KEY (`" . $fieldname . "`) REFERENCES `" . $foreign_table . "` (`" . $foreign_field . "`)";
if (!empty($parameters['foreign']['on update'])) { if (!empty($parameters['foreign']['on update'])) {
$sql .= " ON UPDATE " . strtoupper($parameters['foreign']['on update']); $sql .= " ON UPDATE " . strtoupper($parameters['foreign']['on update']);
@ -981,12 +960,12 @@ class DBStructure
return $sql; return $sql;
} }
private static function addForeignKey(string $tableName, string $fieldName, array $parameters): string private static function addForeignKey(string $tablename, string $fieldname, array $parameters)
{ {
return sprintf("ADD %s", self::foreignCommand($tableName, $fieldName, $parameters)); return sprintf("ADD %s", self::foreignCommand($tablename, $fieldname, $parameters));
} }
private static function dropForeignKey(string $constraint): string private static function dropForeignKey(string $constraint)
{ {
return sprintf("DROP FOREIGN KEY `%s`", $constraint); return sprintf("DROP FOREIGN KEY `%s`", $constraint);
} }
@ -1004,7 +983,7 @@ class DBStructure
* @return boolean Was the renaming successful? * @return boolean Was the renaming successful?
* @throws Exception * @throws Exception
*/ */
public static function rename(string $table, array $columns, int $type = self::RENAME_COLUMN): bool public static function rename($table, $columns, $type = self::RENAME_COLUMN)
{ {
if (empty($table) || empty($columns)) { if (empty($table) || empty($columns)) {
return false; return false;
@ -1040,7 +1019,7 @@ class DBStructure
return false; return false;
} }
$sql .= ';'; $sql .= ";";
$stmt = DBA::p($sql); $stmt = DBA::p($sql);
@ -1100,33 +1079,39 @@ class DBStructure
/** /**
* Check if a foreign key exists for the given table field * Check if a foreign key exists for the given table field
* *
* @param string $table Table name * @param string $table
* @param string $field Field name * @param string $field
* @return boolean Wether a foreign key exists * @return boolean
*/ */
public static function existsForeignKeyForField(string $table, string $field): bool public static function existsForeignKeyForField(string $table, string $field)
{ {
return DBA::exists(['INFORMATION_SCHEMA' => 'KEY_COLUMN_USAGE'], return DBA::exists(['INFORMATION_SCHEMA' => 'KEY_COLUMN_USAGE'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL", ["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL",
DBA::databaseName(), $table, $field]); DBA::databaseName(), $table, $field]);
} }
/** /**
* Check if a table exists * Check if a table exists
*
* @param string|array $table Table name
* *
* @param string $table Single table name (please loop yourself)
* @return boolean Does the table exist? * @return boolean Does the table exist?
* @throws Exception * @throws Exception
*/ */
public static function existsTable(string $table): bool public static function existsTable($table)
{ {
if (empty($table)) { if (empty($table)) {
return false; return false;
} }
$condition = ['table_schema' => DBA::databaseName(), 'table_name' => $table]; if (is_array($table)) {
$condition = ['table_schema' => key($table), 'table_name' => current($table)];
} else {
$condition = ['table_schema' => DBA::databaseName(), 'table_name' => $table];
}
return DBA::exists(['information_schema' => 'tables'], $condition); $result = DBA::exists(['information_schema' => 'tables'], $condition);
return $result;
} }
/** /**
@ -1137,7 +1122,7 @@ class DBStructure
* @return array An array of the table columns * @return array An array of the table columns
* @throws Exception * @throws Exception
*/ */
public static function getColumns(string $table): array public static function getColumns($table)
{ {
$stmtColumns = DBA::p("SHOW COLUMNS FROM `" . $table . "`"); $stmtColumns = DBA::p("SHOW COLUMNS FROM `" . $table . "`");
return DBA::toArray($stmtColumns); return DBA::toArray($stmtColumns);
@ -1145,9 +1130,6 @@ class DBStructure
/** /**
* Check if initial database values do exist - or create them * Check if initial database values do exist - or create them
*
* @param bool $verbose Whether to output messages
* @return void
*/ */
public static function checkInitialValues(bool $verbose = false) public static function checkInitialValues(bool $verbose = false)
{ {
@ -1283,7 +1265,7 @@ class DBStructure
* *
* @return boolean * @return boolean
*/ */
private static function isUpdating(): bool private static function isUpdating()
{ {
$isUpdate = false; $isUpdate = false;

View file

@ -541,7 +541,7 @@ class Database
if (!$retval = $this->connection->query($this->replaceParameters($sql, $args))) { if (!$retval = $this->connection->query($this->replaceParameters($sql, $args))) {
$errorInfo = $this->connection->errorInfo(); $errorInfo = $this->connection->errorInfo();
$this->error = $errorInfo[2]; $this->error = $errorInfo[2];
$this->errorno = (int) $errorInfo[1]; $this->errorno = $errorInfo[1];
$retval = false; $retval = false;
$is_error = true; $is_error = true;
break; break;
@ -554,7 +554,7 @@ class Database
if (!$stmt = $this->connection->prepare($sql)) { if (!$stmt = $this->connection->prepare($sql)) {
$errorInfo = $this->connection->errorInfo(); $errorInfo = $this->connection->errorInfo();
$this->error = $errorInfo[2]; $this->error = $errorInfo[2];
$this->errorno = (int) $errorInfo[1]; $this->errorno = $errorInfo[1];
$retval = false; $retval = false;
$is_error = true; $is_error = true;
break; break;
@ -574,7 +574,7 @@ class Database
if (!$stmt->execute()) { if (!$stmt->execute()) {
$errorInfo = $stmt->errorInfo(); $errorInfo = $stmt->errorInfo();
$this->error = $errorInfo[2]; $this->error = $errorInfo[2];
$this->errorno = (int) $errorInfo[1]; $this->errorno = $errorInfo[1];
$retval = false; $retval = false;
$is_error = true; $is_error = true;
} else { } else {
@ -709,7 +709,7 @@ class Database
} }
$this->error = $error; $this->error = $error;
$this->errorno = (int) $errorno; $this->errorno = $errorno;
} }
$this->profiler->stopRecording(); $this->profiler->stopRecording();
@ -1541,7 +1541,7 @@ class Database
* *
* @return array Data array * @return array Data array
*/ */
public function toArray($stmt, bool $do_close = true, int $count = 0): array public function toArray($stmt, $do_close = true, int $count = 0)
{ {
if (is_bool($stmt)) { if (is_bool($stmt)) {
return []; return [];
@ -1632,7 +1632,7 @@ class Database
* *
* @return string Error number (0 if no error) * @return string Error number (0 if no error)
*/ */
public function errorNo(): int public function errorNo()
{ {
return $this->errorno; return $this->errorno;
} }
@ -1654,7 +1654,7 @@ class Database
* *
* @return boolean was the close successful? * @return boolean was the close successful?
*/ */
public function close($stmt): bool public function close($stmt)
{ {
$this->profiler->startRecording('database'); $this->profiler->startRecording('database');
@ -1696,7 +1696,7 @@ class Database
* 'amount' => Number of concurrent database processes * 'amount' => Number of concurrent database processes
* @throws \Exception * @throws \Exception
*/ */
public function processlist(): array public function processlist()
{ {
$ret = $this->p("SHOW PROCESSLIST"); $ret = $this->p("SHOW PROCESSLIST");
$data = $this->toArray($ret); $data = $this->toArray($ret);

View file

@ -133,7 +133,7 @@ class PostUpdate
} }
$max_item_delivery_data = DBA::selectFirst('item-delivery-data', ['iid'], ['queue_count > 0 OR queue_done > 0'], ['order' => ['iid']]); $max_item_delivery_data = DBA::selectFirst('item-delivery-data', ['iid'], ['queue_count > 0 OR queue_done > 0'], ['order' => ['iid']]);
$max_iid = $max_item_delivery_data['iid'] ?? 0; $max_iid = $max_item_delivery_data['iid'];
Logger::info('Start update1297 with max iid: ' . $max_iid); Logger::info('Start update1297 with max iid: ' . $max_iid);

View file

@ -57,7 +57,7 @@ class Account extends BaseFactory
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException * @throws ImagickException|HTTPException\NotFoundException
*/ */
public function createFromContactId(int $contactId, int $uid = 0): \Friendica\Object\Api\Mastodon\Account public function createFromContactId(int $contactId, $uid = 0): \Friendica\Object\Api\Mastodon\Account
{ {
$contact = Contact::getById($contactId, ['uri-id']); $contact = Contact::getById($contactId, ['uri-id']);
if (empty($contact)) { if (empty($contact)) {
@ -74,7 +74,7 @@ class Account extends BaseFactory
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException * @throws ImagickException|HTTPException\NotFoundException
*/ */
public function createFromUriId(int $contactUriId, int $uid = 0): \Friendica\Object\Api\Mastodon\Account public function createFromUriId(int $contactUriId, $uid = 0): \Friendica\Object\Api\Mastodon\Account
{ {
$account = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]); $account = DBA::selectFirst('account-user-view', [], ['uri-id' => $contactUriId, 'uid' => [0, $uid]], ['order' => ['id' => true]]);
if (empty($account)) { if (empty($account)) {

View file

@ -70,7 +70,6 @@ class Status extends BaseFactory
/** /**
* @param int $uriId Uri-ID of the item * @param int $uriId Uri-ID of the item
* @param int $uid Item user * @param int $uid Item user
* @param bool $include_entities Whether to include entities
* *
* @return \Friendica\Object\Api\Twitter\Status * @return \Friendica\Object\Api\Twitter\Status
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
@ -91,13 +90,12 @@ class Status extends BaseFactory
/** /**
* @param int $uriId Uri-ID of the item * @param int $uriId Uri-ID of the item
* @param int $uid Item user * @param int $uid Item user
* @param bool $include_entities Whether to include entities
* *
* @return \Friendica\Object\Api\Twitter\Status * @return \Friendica\Object\Api\Twitter\Status
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws ImagickException|HTTPException\NotFoundException * @throws ImagickException|HTTPException\NotFoundException
*/ */
public function createFromUriId(int $uriId, int $uid = 0, bool $include_entities = false): \Friendica\Object\Api\Twitter\Status public function createFromUriId(int $uriId, $uid = 0, $include_entities = false): \Friendica\Object\Api\Twitter\Status
{ {
$fields = ['parent-uri-id', 'uri-id', 'uid', 'author-id', 'author-link', 'author-network', 'owner-id', 'causer-id', $fields = ['parent-uri-id', 'uri-id', 'uid', 'author-id', 'author-link', 'author-network', 'owner-id', 'causer-id',
'starred', 'app', 'title', 'body', 'raw-body', 'created', 'network','post-reason', 'language', 'gravity', 'starred', 'app', 'title', 'body', 'raw-body', 'created', 'network','post-reason', 'language', 'gravity',
@ -112,7 +110,6 @@ class Status extends BaseFactory
/** /**
* @param array $item item array * @param array $item item array
* @param int $uid Item user * @param int $uid Item user
* @param bool $include_entities Whether to include entities
* *
* @return \Friendica\Object\Api\Twitter\Status * @return \Friendica\Object\Api\Twitter\Status
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException

View file

@ -51,7 +51,7 @@ class User extends BaseFactory
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public function createFromContactId(int $contactId, int $uid = 0, bool $skip_status = true, bool $include_user_entities = true) public function createFromContactId(int $contactId, $uid = 0, $skip_status = true, $include_user_entities = true)
{ {
$cdata = Contact::getPublicAndUserContactID($contactId, $uid); $cdata = Contact::getPublicAndUserContactID($contactId, $uid);
if (!empty($cdata)) { if (!empty($cdata)) {
@ -78,7 +78,7 @@ class User extends BaseFactory
return new \Friendica\Object\Api\Twitter\User($publicContact, $apcontact, $userContact, $status, $include_user_entities); return new \Friendica\Object\Api\Twitter\User($publicContact, $apcontact, $userContact, $status, $include_user_entities);
} }
public function createFromUserId(int $uid, bool $skip_status = true, bool $include_user_entities = true) public function createFromUserId(int $uid, $skip_status = true, $include_user_entities = true)
{ {
return $this->createFromContactId(Contact::getPublicIdByUserId($uid), $uid, $skip_status, $include_user_entities); return $this->createFromContactId(Contact::getPublicIdByUserId($uid), $uid, $skip_status, $include_user_entities);
} }

View file

@ -57,7 +57,7 @@ class LegacyModule extends BaseModule
* @param string $file_path * @param string $file_path
* @throws \Exception * @throws \Exception
*/ */
private function setModuleFile(string $file_path) private function setModuleFile($file_path)
{ {
if (!is_readable($file_path)) { if (!is_readable($file_path)) {
throw new \Exception(DI::l10n()->t('Legacy module file not found: %s', $file_path)); throw new \Exception(DI::l10n()->t('Legacy module file not found: %s', $file_path));
@ -87,7 +87,7 @@ class LegacyModule extends BaseModule
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
private function runModuleFunction(string $function_suffix): string private function runModuleFunction(string $function_suffix)
{ {
$function_name = $this->moduleName . '_' . $function_suffix; $function_name = $this->moduleName . '_' . $function_suffix;

View file

@ -48,7 +48,7 @@ class APContact
* @param string $addr Address * @param string $addr Address
* @return array webfinger data * @return array webfinger data
*/ */
private static function fetchWebfingerData(string $addr): array private static function fetchWebfingerData(string $addr)
{ {
$addr_parts = explode('@', $addr); $addr_parts = explode('@', $addr);
if (count($addr_parts) != 2) { if (count($addr_parts) != 2) {
@ -117,14 +117,14 @@ class APContact
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getByURL(string $url, $update = null): array public static function getByURL($url, $update = null)
{ {
if (empty($url) || Network::isUrlBlocked($url)) { if (empty($url) || Network::isUrlBlocked($url)) {
Logger::info('Domain is blocked', ['url' => $url]); Logger::info('Domain is blocked', ['url' => $url]);
return []; return [];
} }
$fetched_contact = []; $fetched_contact = false;
if (empty($update)) { if (empty($update)) {
if (is_null($update)) { if (is_null($update)) {
@ -220,14 +220,14 @@ class APContact
$apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type')); $apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
$apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id'); $apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
$apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id'); $apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
$apcontact['inbox'] = (JsonLD::fetchElement($compacted, 'ldp:inbox', '@id') ?? ''); $apcontact['inbox'] = JsonLD::fetchElement($compacted, 'ldp:inbox', '@id');
self::unarchiveInbox($apcontact['inbox'], false); self::unarchiveInbox($apcontact['inbox'], false);
$apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id'); $apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
$apcontact['sharedinbox'] = ''; $apcontact['sharedinbox'] = '';
if (!empty($compacted['as:endpoints'])) { if (!empty($compacted['as:endpoints'])) {
$apcontact['sharedinbox'] = (JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id') ?? ''); $apcontact['sharedinbox'] = JsonLD::fetchElement($compacted['as:endpoints'], 'as:sharedInbox', '@id');
self::unarchiveInbox($apcontact['sharedinbox'], true); self::unarchiveInbox($apcontact['sharedinbox'], true);
} }
@ -241,10 +241,9 @@ class APContact
$apcontact['name'] = $apcontact['nick']; $apcontact['name'] = $apcontact['nick'];
} }
$apcontact['about'] = HTML::toBBCode(JsonLD::fetchElement($compacted, 'as:summary', '@value') ?? ''); $apcontact['about'] = HTML::toBBCode(JsonLD::fetchElement($compacted, 'as:summary', '@value'));
$ims = JsonLD::fetchElementArray($compacted, 'vcard:hasInstantMessage'); $ims = JsonLD::fetchElementArray($compacted, 'vcard:hasInstantMessage');
if (!empty($ims)) { if (!empty($ims)) {
foreach ($ims as $link) { foreach ($ims as $link) {
if (substr($link, 0, 5) == 'xmpp:') { if (substr($link, 0, 5) == 'xmpp:') {
@ -526,9 +525,8 @@ class APContact
* *
* @param string $url inbox url * @param string $url inbox url
* @param boolean $shared Shared Inbox * @param boolean $shared Shared Inbox
* @return void
*/ */
private static function unarchiveInbox(string $url, bool $shared) private static function unarchiveInbox($url, $shared)
{ {
if (empty($url)) { if (empty($url)) {
return; return;

View file

@ -44,7 +44,7 @@ class Attach
* @return array field list * @return array field list
* @throws \Exception * @throws \Exception
*/ */
private static function getFields(): array private static function getFields()
{ {
$allfields = DBStructure::definition(DI::app()->getBasePath(), false); $allfields = DBStructure::definition(DI::app()->getBasePath(), false);
$fields = array_keys($allfields['attach']['fields']); $fields = array_keys($allfields['attach']['fields']);
@ -59,7 +59,7 @@ class Attach
* @param array $conditions Array of fields for conditions * @param array $conditions Array of fields for conditions
* @param array $params Array of several parameters * @param array $params Array of several parameters
* *
* @return array|bool * @return array
* *
* @throws \Exception * @throws \Exception
* @see \Friendica\Database\DBA::selectToArray * @see \Friendica\Database\DBA::selectToArray
@ -102,7 +102,7 @@ class Attach
* @return boolean * @return boolean
* @throws \Exception * @throws \Exception
*/ */
public static function exists(array $conditions): bool public static function exists(array $conditions)
{ {
return DBA::exists('attach', $conditions); return DBA::exists('attach', $conditions);
} }
@ -117,7 +117,7 @@ class Attach
* @throws \Exception * @throws \Exception
* @see \Friendica\Database\DBA::select * @see \Friendica\Database\DBA::select
*/ */
public static function getById(int $id) public static function getById($id)
{ {
return self::selectFirst([], ['id' => $id]); return self::selectFirst([], ['id' => $id]);
} }
@ -132,7 +132,7 @@ class Attach
* @throws \Exception * @throws \Exception
* @see \Friendica\Database\DBA::select * @see \Friendica\Database\DBA::select
*/ */
public static function getByIdWithPermission(int $id) public static function getByIdWithPermission($id)
{ {
$r = self::selectFirst(['uid'], ['id' => $id]); $r = self::selectFirst(['uid'], ['id' => $id]);
if ($r === false) { if ($r === false) {
@ -156,10 +156,10 @@ class Attach
* *
* @param array $item Attachment data. Needs at least 'id', 'backend-class', 'backend-ref' * @param array $item Attachment data. Needs at least 'id', 'backend-class', 'backend-ref'
* *
* @return string|null file data or null on failure * @return string file data
* @throws \Exception * @throws \Exception
*/ */
public static function getData(array $item) public static function getData($item)
{ {
if (!empty($item['data'])) { if (!empty($item['data'])) {
return $item['data']; return $item['data'];
@ -195,10 +195,10 @@ class Attach
* @param string $deny_cid Permissions, denied contacts.optional, default = '' * @param string $deny_cid Permissions, denied contacts.optional, default = ''
* @param string $deny_gid Permissions, denied greoup.optional, default = '' * @param string $deny_gid Permissions, denied greoup.optional, default = ''
* *
* @return boolean|integer Row id on success, False on errors * @return boolean/integer Row id on success, False on errors
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function store(string $data, int $uid, string $filename, string $filetype = '' , int $filesize = null, string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '') public static function store($data, $uid, $filename, $filetype = '' , $filesize = null, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
{ {
if ($filetype === '') { if ($filetype === '') {
$filetype = Mimetype::getContentType($filename); $filetype = Mimetype::getContentType($filename);
@ -241,17 +241,17 @@ class Attach
/** /**
* Store new file metadata in db and binary in default backend from existing file * Store new file metadata in db and binary in default backend from existing file
* *
* @param string $src Source file name * @param $src
* @param int $uid User id * @param $uid
* @param string $filename Optional file name * @param string $filename
* @param string $allow_cid * @param string $allow_cid
* @param string $allow_gid * @param string $allow_gid
* @param string $deny_cid * @param string $deny_cid
* @param string $deny_gid * @param string $deny_gid
* @return boolean|int Insert id or false on failure * @return boolean True on success
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function storeFile(string $src, int $uid, string $filename = '', string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '') public static function storeFile($src, $uid, $filename = '', $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '')
{ {
if ($filename === '') { if ($filename === '') {
$filename = basename($src); $filename = basename($src);
@ -276,7 +276,7 @@ class Attach
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @see \Friendica\Database\DBA::update * @see \Friendica\Database\DBA::update
*/ */
public static function update(array $fields, array $conditions, Image $img = null, array $old_fields = []): bool public static function update($fields, $conditions, Image $img = null, array $old_fields = [])
{ {
if (!is_null($img)) { if (!is_null($img)) {
// get items to update // get items to update
@ -311,7 +311,7 @@ class Attach
* @throws \Exception * @throws \Exception
* @see \Friendica\Database\DBA::delete * @see \Friendica\Database\DBA::delete
*/ */
public static function delete(array $conditions, array $options = []): bool public static function delete(array $conditions, array $options = [])
{ {
// get items to delete data info // get items to delete data info
$items = self::selectToArray(['backend-class','backend-ref'], $conditions); $items = self::selectToArray(['backend-class','backend-ref'], $conditions);

View file

@ -119,7 +119,7 @@ class Contact
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function selectToArray(array $fields = [], array $condition = [], array $params = []): array public static function selectToArray(array $fields = [], array $condition = [], array $params = [])
{ {
return DBA::selectToArray('contact', $fields, $condition, $params); return DBA::selectToArray('contact', $fields, $condition, $params);
} }
@ -128,7 +128,7 @@ class Contact
* @param array $fields Array of selected fields, empty for all * @param array $fields Array of selected fields, empty for all
* @param array $condition Array of fields for condition * @param array $condition Array of fields for condition
* @param array $params Array of several parameters * @param array $params Array of several parameters
* @return array|bool * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function selectFirst(array $fields = [], array $condition = [], array $params = []) public static function selectFirst(array $fields = [], array $condition = [], array $params = [])
@ -148,7 +148,7 @@ class Contact
* @return int id of the created contact * @return int id of the created contact
* @throws \Exception * @throws \Exception
*/ */
public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT): int public static function insert(array $fields, int $duplicate_mode = Database::INSERT_DEFAULT)
{ {
if (!empty($fields['baseurl']) && empty($fields['gsid'])) { if (!empty($fields['baseurl']) && empty($fields['gsid'])) {
$fields['gsid'] = GServer::getID($fields['baseurl'], true); $fields['gsid'] = GServer::getID($fields['baseurl'], true);
@ -187,7 +187,6 @@ class Contact
* *
* @return boolean was the update successfull? * @return boolean was the update successfull?
* @throws \Exception * @throws \Exception
* @todo Let's get rid of boolean type of $old_fields
*/ */
public static function update(array $fields, array $condition, $old_fields = []) public static function update(array $fields, array $condition, $old_fields = [])
{ {
@ -205,7 +204,7 @@ class Contact
* @return array|boolean Contact record if it exists, false otherwise * @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception * @throws \Exception
*/ */
public static function getById(int $id, array $fields = []) public static function getById($id, $fields = [])
{ {
return DBA::selectFirst('contact', $fields, ['id' => $id]); return DBA::selectFirst('contact', $fields, ['id' => $id]);
} }
@ -218,7 +217,7 @@ class Contact
* @return array|boolean Contact record if it exists, false otherwise * @return array|boolean Contact record if it exists, false otherwise
* @throws \Exception * @throws \Exception
*/ */
public static function getByUriId(int $uri_id, array $fields = []) public static function getByUriId($uri_id, $fields = [])
{ {
return DBA::selectFirst('contact', $fields, ['uri-id' => $uri_id], ['order' => ['uid']]); return DBA::selectFirst('contact', $fields, ['uri-id' => $uri_id], ['order' => ['uid']]);
} }
@ -232,7 +231,7 @@ class Contact
* @param integer $uid User ID of the contact * @param integer $uid User ID of the contact
* @return array contact array * @return array contact array
*/ */
public static function getByURL(string $url, $update = null, array $fields = [], int $uid = 0): array public static function getByURL(string $url, $update = null, array $fields = [], int $uid = 0)
{ {
if ($update || is_null($update)) { if ($update || is_null($update)) {
$cid = self::getIdForURL($url, $uid, $update); $cid = self::getIdForURL($url, $uid, $update);
@ -303,7 +302,7 @@ class Contact
* @param array $fields Field list * @param array $fields Field list
* @return array contact array * @return array contact array
*/ */
public static function getByURLForUser(string $url, int $uid = 0, $update = false, array $fields = []): array public static function getByURLForUser(string $url, int $uid = 0, $update = false, array $fields = [])
{ {
if ($uid != 0) { if ($uid != 0) {
$contact = self::getByURL($url, $update, $fields, $uid); $contact = self::getByURL($url, $update, $fields, $uid);
@ -334,7 +333,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isFollower(int $cid, int $uid): bool public static function isFollower($cid, $uid)
{ {
if (Contact\User::isBlocked($cid, $uid)) { if (Contact\User::isBlocked($cid, $uid)) {
return false; return false;
@ -359,7 +358,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isFollowerByURL(string $url, uid $uid): bool public static function isFollowerByURL($url, $uid)
{ {
$cid = self::getIdForURL($url, $uid); $cid = self::getIdForURL($url, $uid);
@ -371,16 +370,16 @@ class Contact
} }
/** /**
* Tests if the given user shares with the given contact * Tests if the given user follow the given contact
* *
* @param int $cid Either public contact id or user's contact id * @param int $cid Either public contact id or user's contact id
* @param int $uid User ID * @param int $uid User ID
* *
* @return boolean is the contact sharing with given user? * @return boolean is the contact url being followed?
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isSharing(int $cid, int $uid): bool public static function isSharing($cid, $uid)
{ {
if (Contact\User::isBlocked($cid, $uid)) { if (Contact\User::isBlocked($cid, $uid)) {
return false; return false;
@ -405,7 +404,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isSharingByURL(string $url, int $uid): bool public static function isSharingByURL($url, $uid)
{ {
$cid = self::getIdForURL($url, $uid); $cid = self::getIdForURL($url, $uid);
@ -426,7 +425,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getBasepath(string $url, bool $dont_update = false): string public static function getBasepath($url, $dont_update = false)
{ {
$contact = DBA::selectFirst('contact', ['id', 'baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]); $contact = DBA::selectFirst('contact', ['id', 'baseurl'], ['uid' => 0, 'nurl' => Strings::normaliseLink($url)]);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
@ -460,7 +459,7 @@ class Contact
* *
* @return boolean Is it the same server? * @return boolean Is it the same server?
*/ */
public static function isLocal(string $url): bool public static function isLocal($url)
{ {
if (!parse_url($url, PHP_URL_SCHEME)) { if (!parse_url($url, PHP_URL_SCHEME)) {
$addr_parts = explode('@', $url); $addr_parts = explode('@', $url);
@ -477,7 +476,7 @@ class Contact
* *
* @return boolean Is it the same server? * @return boolean Is it the same server?
*/ */
public static function isLocalById(int $cid): bool public static function isLocalById(int $cid)
{ {
$contact = DBA::selectFirst('contact', ['url', 'baseurl'], ['id' => $cid]); $contact = DBA::selectFirst('contact', ['url', 'baseurl'], ['id' => $cid]);
if (!DBA::isResult($contact)) { if (!DBA::isResult($contact)) {
@ -501,7 +500,7 @@ class Contact
* @return integer|boolean Public contact id for given user id * @return integer|boolean Public contact id for given user id
* @throws \Exception * @throws \Exception
*/ */
public static function getPublicIdByUserId(int $uid) public static function getPublicIdByUserId($uid)
{ {
$self = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]); $self = DBA::selectFirst('contact', ['url'], ['self' => true, 'uid' => $uid]);
if (!DBA::isResult($self)) { if (!DBA::isResult($self)) {
@ -520,7 +519,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getPublicAndUserContactID(int $cid, int $uid): array public static function getPublicAndUserContactID($cid, $uid)
{ {
// We have to use the legacy function as long as the post update hasn't finished // We have to use the legacy function as long as the post update hasn't finished
if (DI::config()->get('system', 'post_update_version') < 1427) { if (DI::config()->get('system', 'post_update_version') < 1427) {
@ -561,7 +560,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function legacyGetPublicAndUserContactID(int $cid, int $uid): array private static function legacyGetPublicAndUserContactID($cid, $uid)
{ {
if (empty($uid) || empty($cid)) { if (empty($uid) || empty($cid)) {
return []; return [];
@ -1527,7 +1526,7 @@ class Contact
* @param int $type type of contact or account * @param int $type type of contact or account
* @return string * @return string
*/ */
public static function getAccountType(int $type): string public static function getAccountType(int $type)
{ {
switch ($type) { switch ($type) {
case self::TYPE_ORGANISATION: case self::TYPE_ORGANISATION:
@ -1553,11 +1552,11 @@ class Contact
/** /**
* Blocks a contact * Blocks a contact
* *
* @param int $cid Contact id to block * @param int $cid
* @param string $reason Block reason * @return bool
* @return bool Whether it was successful * @throws \Exception
*/ */
public static function block(int $cid, string $reason = null): bool public static function block($cid, $reason = null)
{ {
$return = self::update(['blocked' => true, 'block_reason' => $reason], ['id' => $cid]); $return = self::update(['blocked' => true, 'block_reason' => $reason], ['id' => $cid]);
@ -1567,10 +1566,11 @@ class Contact
/** /**
* Unblocks a contact * Unblocks a contact
* *
* @param int $cid Contact id to unblock * @param int $cid
* @return bool Whether it was successfull * @return bool
* @throws \Exception
*/ */
public static function unblock(int $cid): bool public static function unblock($cid)
{ {
$return = self::update(['blocked' => false, 'block_reason' => null], ['id' => $cid]); $return = self::update(['blocked' => false, 'block_reason' => null], ['id' => $cid]);
@ -1580,7 +1580,7 @@ class Contact
/** /**
* Ensure that cached avatar exist * Ensure that cached avatar exist
* *
* @param integer $cid Contact id * @param integer $cid
*/ */
public static function checkAvatarCache(int $cid) public static function checkAvatarCache(int $cid)
{ {
@ -1620,7 +1620,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path * @return string photo path
*/ */
private static function getAvatarPath(array $contact, string $size, bool $no_update = false): string private static function getAvatarPath(array $contact, string $size, $no_update = false)
{ {
$contact = self::checkAvatarCacheByArray($contact, $no_update); $contact = self::checkAvatarCacheByArray($contact, $no_update);
@ -1654,7 +1654,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path * @return string photo path
*/ */
public static function getPhoto(array $contact, bool $no_update = false): string public static function getPhoto(array $contact, bool $no_update = false)
{ {
return self::getAvatarPath($contact, Proxy::SIZE_SMALL, $no_update); return self::getAvatarPath($contact, Proxy::SIZE_SMALL, $no_update);
} }
@ -1666,7 +1666,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path * @return string photo path
*/ */
public static function getThumb(array $contact, bool $no_update = false): string public static function getThumb(array $contact, bool $no_update = false)
{ {
return self::getAvatarPath($contact, Proxy::SIZE_THUMB, $no_update); return self::getAvatarPath($contact, Proxy::SIZE_THUMB, $no_update);
} }
@ -1678,7 +1678,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return string photo path * @return string photo path
*/ */
public static function getMicro(array $contact, bool $no_update = false): string public static function getMicro(array $contact, bool $no_update = false)
{ {
return self::getAvatarPath($contact, Proxy::SIZE_MICRO, $no_update); return self::getAvatarPath($contact, Proxy::SIZE_MICRO, $no_update);
} }
@ -1690,7 +1690,7 @@ class Contact
* @param bool $no_update Don't perfom an update if no cached avatar was found * @param bool $no_update Don't perfom an update if no cached avatar was found
* @return array contact array with avatar cache fields * @return array contact array with avatar cache fields
*/ */
private static function checkAvatarCacheByArray(array $contact, bool $no_update = false): array private static function checkAvatarCacheByArray(array $contact, bool $no_update = false)
{ {
$update = false; $update = false;
$contact_fields = []; $contact_fields = [];
@ -1796,7 +1796,7 @@ class Contact
* @param string $size Size of the avatar picture * @param string $size Size of the avatar picture
* @return string avatar URL * @return string avatar URL
*/ */
public static function getDefaultAvatar(array $contact, string $size): string public static function getDefaultAvatar(array $contact, string $size)
{ {
switch ($size) { switch ($size) {
case Proxy::SIZE_MICRO: case Proxy::SIZE_MICRO:
@ -1817,114 +1817,6 @@ class Contact
} }
if (!DI::config()->get('system', 'remote_avatar_lookup')) { if (!DI::config()->get('system', 'remote_avatar_lookup')) {
$platform = '';
$type = Contact::TYPE_PERSON;
if (!empty($contact['id'])) {
$account = DBA::selectFirst('account-user-view', ['platform', 'contact-type'], ['id' => $contact['id']]);
$platform = $account['platform'] ?? '';
$type = $account['contact-type'] ?? Contact::TYPE_PERSON;
}
if (empty($platform) && !empty($contact['uri-id'])) {
$account = DBA::selectFirst('account-user-view', ['platform', 'contact-type'], ['uri-id' => $contact['uri-id']]);
$platform = $account['platform'] ?? '';
$type = $account['contact-type'] ?? Contact::TYPE_PERSON;
}
switch ($platform) {
case 'corgidon':
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/msdos621/corgidon/blob/main/public/avatars/original/missing.png
*/
$default = '/images/default/corgidon.png';
break;
case 'diaspora':
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/diaspora/diaspora/
*/
$default = '/images/default/diaspora.png';
break;
case 'gotosocial':
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/superseriousbusiness/gotosocial/blob/main/web/assets/default_avatars/GoToSocial_icon1.svg
*/
$default = '/images/default/gotosocial.svg';
break;
case 'hometown':
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/hometown-fork/hometown/blob/hometown-dev/public/avatars/original/missing.png
*/
$default = '/images/default/hometown.png';
break;
case 'koyuspace':
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/koyuspace/mastodon/blob/main/public/avatars/original/missing.png
*/
$default = '/images/default/koyuspace.png';
break;
case 'ecko':
case 'qoto':
case 'mastodon':
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/mastodon/mastodon/tree/main/public/avatars/original/missing.png
*/
$default = '/images/default/mastodon.png';
break;
case 'peertube':
if ($type == Contact::TYPE_COMMUNITY) {
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/Chocobozzz/PeerTube/blob/develop/client/src/assets/images/default-avatar-video-channel.png
*/
$default = '/images/default/peertube-channel.png';
} else {
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/Chocobozzz/PeerTube/blob/develop/client/src/assets/images/default-avatar-account.png
*/
$default = '/images/default/peertube-account.png';
}
break;
case 'pleroma':
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://git.pleroma.social/pleroma/pleroma/-/blob/develop/priv/static/images/avi.png
*/
$default = '/images/default/pleroma.png';
break;
case 'plume':
/**
* Picture credits
* @license GNU Affero General Public License v3.0
* @link https://github.com/Plume-org/Plume/blob/main/assets/images/default-avatar.png
*/
$default = '/images/default/plume.png';
break;
}
return DI::baseUrl() . $default; return DI::baseUrl() . $default;
} }
@ -2614,7 +2506,7 @@ class Contact
* @throws HTTPException\NotFoundException * @throws HTTPException\NotFoundException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function createFromProbeForUser(int $uid, string $url, string $network = ''): array public static function createFromProbeForUser(int $uid, $url, $network = '')
{ {
$result = ['cid' => -1, 'success' => false, 'message' => '']; $result = ['cid' => -1, 'success' => false, 'message' => ''];
@ -2803,7 +2695,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function addRelationship(array $importer, array $contact, array $datarray, bool $sharing = false, string $note = '') public static function addRelationship(array $importer, array $contact, array $datarray, $sharing = false, $note = '')
{ {
// Should always be set // Should always be set
if (empty($datarray['author-id'])) { if (empty($datarray['author-id'])) {
@ -3030,7 +2922,7 @@ class Contact
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function pruneUnavailable(array $contact_ids): array public static function pruneUnavailable(array $contact_ids)
{ {
if (empty($contact_ids)) { if (empty($contact_ids)) {
return []; return [];
@ -3058,7 +2950,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function magicLink(string $contact_url, string $url = ''): string public static function magicLink($contact_url, $url = '')
{ {
if (!Session::isAuthenticated()) { if (!Session::isAuthenticated()) {
return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url; return $url ?: $contact_url; // Equivalent to: ($url != '') ? $url : $contact_url;
@ -3085,7 +2977,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function magicLinkById(int $cid, string $url = ''): string public static function magicLinkById($cid, $url = '')
{ {
$contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], ['id' => $cid]); $contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], ['id' => $cid]);
@ -3102,7 +2994,7 @@ class Contact
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function magicLinkByContact(array $contact, string $url = ''): string public static function magicLinkByContact($contact, $url = '')
{ {
$destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url']; $destination = $url ?: $contact['url']; // Equivalent to ($url != '') ? $url : $contact['url'];
@ -3143,7 +3035,7 @@ class Contact
* *
* @return boolean "true" if it is a forum * @return boolean "true" if it is a forum
*/ */
public static function isForum(int $contactid): bool public static function isForum($contactid)
{ {
$fields = ['contact-type']; $fields = ['contact-type'];
$condition = ['id' => $contactid]; $condition = ['id' => $contactid];
@ -3162,7 +3054,7 @@ class Contact
* @param array $contact * @param array $contact
* @return bool * @return bool
*/ */
public static function canReceivePrivateMessages(array $contact): bool public static function canReceivePrivateMessages(array $contact)
{ {
$protocol = $contact['network'] ?? $contact['protocol'] ?? Protocol::PHANTOM; $protocol = $contact['network'] ?? $contact['protocol'] ?? Protocol::PHANTOM;
$self = $contact['self'] ?? false; $self = $contact['self'] ?? false;
@ -3180,7 +3072,7 @@ class Contact
* @return array with search results * @return array with search results
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function searchByName(string $search, string $mode = '', int $uid = 0): array public static function searchByName(string $search, string $mode = '', int $uid = 0)
{ {
if (empty($search)) { if (empty($search)) {
return []; return [];
@ -3223,7 +3115,7 @@ class Contact
* @param array $urls * @param array $urls
* @return array result "count", "added" and "updated" * @return array result "count", "added" and "updated"
*/ */
public static function addByUrls(array $urls): array public static function addByUrls(array $urls)
{ {
$added = 0; $added = 0;
$updated = 0; $updated = 0;
@ -3256,7 +3148,7 @@ class Contact
* @return array The profile array * @return array The profile array
* @throws Exception * @throws Exception
*/ */
public static function getRandomContact(): array public static function getRandomContact()
{ {
$contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], [ $contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], [
"`uid` = ? AND `network` = ? AND NOT `failed` AND `last-item` > ?", "`uid` = ? AND `network` = ? AND NOT `failed` AND `last-item` > ?",

View file

@ -62,7 +62,7 @@ class Conversation
*/ */
const RELAY = 3; const RELAY = 3;
public static function getByItemUri(string $item_uri) public static function getByItemUri($item_uri)
{ {
return DBA::selectFirst('conversation', [], ['item-uri' => $item_uri]); return DBA::selectFirst('conversation', [], ['item-uri' => $item_uri]);
} }
@ -74,7 +74,7 @@ class Conversation
* @return array Item array with removed conversation data * @return array Item array with removed conversation data
* @throws \Exception * @throws \Exception
*/ */
public static function insert(array $arr): array public static function insert(array $arr)
{ {
if (in_array(($arr['network'] ?? '') ?: Protocol::PHANTOM, if (in_array(($arr['network'] ?? '') ?: Protocol::PHANTOM,
[Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) { [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS, Protocol::TWITTER]) && !empty($arr['uri'])) {

View file

@ -41,7 +41,7 @@ use Friendica\Util\XML;
class Event class Event
{ {
public static function getHTML(array $event, bool $simple = false, int $uriid = 0): string public static function getHTML(array $event, $simple = false, $uriid = 0)
{ {
if (empty($event)) { if (empty($event)) {
return ''; return '';
@ -127,7 +127,7 @@ class Event
* @param array $event Array which contains the event data. * @param array $event Array which contains the event data.
* @return string The event as a bbcode formatted string. * @return string The event as a bbcode formatted string.
*/ */
private static function getBBCode(array $event): string private static function getBBCode(array $event)
{ {
$o = ''; $o = '';
@ -157,10 +157,11 @@ class Event
/** /**
* Extract bbcode formatted event data from a string. * Extract bbcode formatted event data from a string.
* *
* @param string $text The string which should be parsed for event data. * @params: string $s The string which should be parsed for event data.
* @param $text
* @return array The array with the event information. * @return array The array with the event information.
*/ */
public static function fromBBCode(string $text): array public static function fromBBCode($text)
{ {
$ev = []; $ev = [];
@ -194,13 +195,13 @@ class Event
return $ev; return $ev;
} }
public static function sortByDate(array $event_list): array public static function sortByDate($event_list)
{ {
usort($event_list, ['self', 'compareDatesCallback']); usort($event_list, ['self', 'compareDatesCallback']);
return $event_list; return $event_list;
} }
private static function compareDatesCallback(array $event_a, array $event_b) private static function compareDatesCallback($event_a, $event_b)
{ {
$date_a = DateTimeFormat::local($event_a['start']); $date_a = DateTimeFormat::local($event_a['start']);
$date_b = DateTimeFormat::local($event_b['start']); $date_b = DateTimeFormat::local($event_b['start']);
@ -222,7 +223,7 @@ class Event
* @return void * @return void
* @throws \Exception * @throws \Exception
*/ */
public static function delete(int $event_id) public static function delete($event_id)
{ {
if ($event_id == 0) { if ($event_id == 0) {
return; return;
@ -241,7 +242,7 @@ class Event
* @return int The new event id. * @return int The new event id.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function store(array $arr): int public static function store($arr)
{ {
$event = []; $event = [];
$event['id'] = intval($arr['id'] ?? 0); $event['id'] = intval($arr['id'] ?? 0);
@ -316,7 +317,7 @@ class Event
return $event['id']; return $event['id'];
} }
public static function getItemArrayForId(int $event_id, array $item = []): array public static function getItemArrayForId(int $event_id, array $item = []):array
{ {
if (empty($event_id)) { if (empty($event_id)) {
return $item; return $item;
@ -373,7 +374,7 @@ class Event
return $item; return $item;
} }
public static function getItemArrayForImportedId(int $event_id, array $item = []): array public static function getItemArrayForImportedId(int $event_id, array $item = []):array
{ {
if (empty($event_id)) { if (empty($event_id)) {
return $item; return $item;
@ -403,7 +404,7 @@ class Event
* @return array Array with translations strings. * @return array Array with translations strings.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function getStrings(): array public static function getStrings()
{ {
// First day of the week (0 = Sunday). // First day of the week (0 = Sunday).
$firstDay = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0); $firstDay = DI::pConfig()->get(local_user(), 'system', 'first_day_of_week', 0);
@ -476,7 +477,7 @@ class Event
* *
* @todo We should replace this with a separate update function if there is some time left. * @todo We should replace this with a separate update function if there is some time left.
*/ */
private static function removeDuplicates(array $dates): array private static function removeDuplicates(array $dates)
{ {
$dates2 = []; $dates2 = [];
@ -499,7 +500,7 @@ class Event
* @return array Query result * @return array Query result
* @throws \Exception * @throws \Exception
*/ */
public static function getListById(int $owner_uid, int $event_id, string $sql_extra = ''): array public static function getListById($owner_uid, $event_id, $sql_extra = '')
{ {
$return = []; $return = [];
@ -535,7 +536,7 @@ class Event
* @return array Query results. * @return array Query results.
* @throws \Exception * @throws \Exception
*/ */
public static function getListByDate(int $owner_uid, array $event_params, string $sql_extra = ''): array public static function getListByDate($owner_uid, $event_params, $sql_extra = '')
{ {
$return = []; $return = [];
@ -569,7 +570,7 @@ class Event
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function prepareListForTemplate(array $event_result): array public static function prepareListForTemplate(array $event_result)
{ {
$event_list = []; $event_list = [];
@ -650,12 +651,12 @@ class Event
* @param array $events Query result for events. * @param array $events Query result for events.
* @param string $format The output format (ical/csv). * @param string $format The output format (ical/csv).
* *
* @param string $timezone Timezone (missing parameter!) * @param $timezone
* @return string Content according to selected export format. * @return string Content according to selected export format.
* *
* @todo Implement timezone support * @todo Implement timezone support
*/ */
private static function formatListForExport(array $events, string $format): string private static function formatListForExport(array $events, $format)
{ {
$o = ''; $o = '';
@ -756,7 +757,7 @@ class Event
* @return array Query results. * @return array Query results.
* @throws \Exception * @throws \Exception
*/ */
private static function getListByUserId(int $uid = 0): array private static function getListByUserId($uid = 0)
{ {
$return = []; $return = [];
@ -796,7 +797,7 @@ class Event
* @throws \Exception * @throws \Exception
* @todo Respect authenticated users with events_by_uid(). * @todo Respect authenticated users with events_by_uid().
*/ */
public static function exportListByUserId(int $uid, string $format = 'ical'): array public static function exportListByUserId($uid, $format = 'ical')
{ {
$process = false; $process = false;
@ -844,8 +845,7 @@ class Event
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getItemHTML(array $item): string public static function getItemHTML(array $item) {
{
$same_date = false; $same_date = false;
$finish = false; $finish = false;
@ -933,11 +933,10 @@ class Event
* @return array The array with the location data. * @return array The array with the location data.
* 'name' => The name of the location,<br> * 'name' => The name of the location,<br>
* 'address' => The address of the location,<br> * 'address' => The address of the location,<br>
* 'coordinates' => Latitude and longitude (e.g. '48.864716,2.349014').<br> * 'coordinates' => Latitude and longitude (e.g. '48.864716,2.349014').<br>
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function locationToArray(string $s = ''): array private static function locationToArray($s = '') {
{
if ($s == '') { if ($s == '') {
return []; return [];
} }
@ -982,7 +981,7 @@ class Event
* @return bool * @return bool
* @throws \Exception * @throws \Exception
*/ */
public static function createBirthday(array $contact, string $birthday): bool public static function createBirthday($contact, $birthday)
{ {
// Check for duplicates // Check for duplicates
$condition = [ $condition = [
@ -1012,7 +1011,8 @@ class Event
'type' => 'birthday', 'type' => 'birthday',
]; ];
// Check if self::store() was success self::store($values);
return (self::store($values) > 0);
return true;
} }
} }

View file

@ -40,7 +40,7 @@ class FContact
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function getByURL(string $handle, $update = null): array public static function getByURL($handle, $update = null)
{ {
$person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]); $person = DBA::selectFirst('fcontact', [], ['network' => Protocol::DIASPORA, 'addr' => $handle]);
if (!DBA::isResult($person)) { if (!DBA::isResult($person)) {
@ -90,7 +90,7 @@ class FContact
* @param array $arr The fcontact data * @param array $arr The fcontact data
* @throws \Exception * @throws \Exception
*/ */
public static function updateFromProbeArray(array $arr) public static function updateFromProbeArray($arr)
{ {
$uriid = ItemURI::insert(['uri' => $arr['url'], 'guid' => $arr['guid']]); $uriid = ItemURI::insert(['uri' => $arr['url'], 'guid' => $arr['guid']]);
@ -122,12 +122,12 @@ class FContact
* get a url (scheme://domain.tld/u/user) from a given Diaspora* * get a url (scheme://domain.tld/u/user) from a given Diaspora*
* fcontact guid * fcontact guid
* *
* @param string $fcontact_guid Hexadecimal string guid * @param mixed $fcontact_guid Hexadecimal string guid
* *
* @return string|null the contact url or null * @return string the contact url or null
* @throws \Exception * @throws \Exception
*/ */
public static function getUrlByGuid(string $fcontact_guid) public static function getUrlByGuid($fcontact_guid)
{ {
Logger::info('fcontact', ['guid' => $fcontact_guid]); Logger::info('fcontact', ['guid' => $fcontact_guid]);

View file

@ -35,9 +35,10 @@ class FileTag
* URL encode <, >, left and right brackets * URL encode <, >, left and right brackets
* *
* @param string $s String to be URL encoded. * @param string $s String to be URL encoded.
*
* @return string The URL encoded string. * @return string The URL encoded string.
*/ */
private static function encode(string $s): string private static function encode($s)
{ {
return str_replace(['<', '>', '[', ']'], ['%3c', '%3e', '%5b', '%5d'], $s); return str_replace(['<', '>', '[', ']'], ['%3c', '%3e', '%5b', '%5d'], $s);
} }
@ -46,9 +47,10 @@ class FileTag
* URL decode <, >, left and right brackets * URL decode <, >, left and right brackets
* *
* @param string $s The URL encoded string to be decoded * @param string $s The URL encoded string to be decoded
*
* @return string The decoded string. * @return string The decoded string.
*/ */
private static function decode(string $s): string private static function decode($s)
{ {
return str_replace(['%3c', '%3e', '%5b', '%5d'], ['<', '>', '[', ']'], $s); return str_replace(['%3c', '%3e', '%5b', '%5d'], ['<', '>', '[', ']'], $s);
} }
@ -60,9 +62,10 @@ class FileTag
* *
* @param array $array A list of tags. * @param array $array A list of tags.
* @param string $type Optional file type. * @param string $type Optional file type.
*
* @return string A list of file tags. * @return string A list of file tags.
*/ */
public static function arrayToFile(array $array, string $type = 'file'): string public static function arrayToFile(array $array, string $type = 'file')
{ {
$tag_list = ''; $tag_list = '';
if ($type == 'file') { if ($type == 'file') {
@ -89,9 +92,10 @@ class FileTag
* *
* @param string $file File tags * @param string $file File tags
* @param string $type Optional file type. * @param string $type Optional file type.
*
* @return array List of tag names. * @return array List of tag names.
*/ */
public static function fileToArray(string $file, string $type = 'file'): array public static function fileToArray(string $file, string $type = 'file')
{ {
$matches = []; $matches = [];
$return = []; $return = [];

View file

@ -96,7 +96,7 @@ class GServer
* *
* @param string $url * @param string $url
* @param boolean $no_check Don't check if the server hadn't been found * @param boolean $no_check Don't check if the server hadn't been found
* @return int|null gserver id or NULL on empty URL or failed check * @return int gserver id
*/ */
public static function getID(string $url, bool $no_check = false) public static function getID(string $url, bool $no_check = false)
{ {
@ -156,7 +156,7 @@ class GServer
* *
* @return boolean 'true' if server seems vital * @return boolean 'true' if server seems vital
*/ */
public static function reachable(string $profile, string $server = '', string $network = '', bool $force = false): bool public static function reachable(string $profile, string $server = '', string $network = '', bool $force = false)
{ {
if ($server == '') { if ($server == '') {
$contact = Contact::getByURL($profile, null, ['baseurl']); $contact = Contact::getByURL($profile, null, ['baseurl']);
@ -172,7 +172,7 @@ class GServer
return self::check($server, $network, $force); return self::check($server, $network, $force);
} }
public static function getNextUpdateDate(bool $success, string $created = '', string $last_contact = ''): string public static function getNextUpdateDate(bool $success, string $created = '', string $last_contact = '')
{ {
// On successful contact process check again next week // On successful contact process check again next week
if ($success) { if ($success) {
@ -231,7 +231,7 @@ class GServer
* *
* @return boolean 'true' if server seems vital * @return boolean 'true' if server seems vital
*/ */
public static function check(string $server_url, string $network = '', bool $force = false, bool $only_nodeinfo = false): bool public static function check(string $server_url, string $network = '', bool $force = false, bool $only_nodeinfo = false)
{ {
$server_url = self::cleanURL($server_url); $server_url = self::cleanURL($server_url);
if ($server_url == '') { if ($server_url == '') {
@ -286,7 +286,7 @@ class GServer
* @param string $url * @param string $url
* @return string cleaned URL * @return string cleaned URL
*/ */
public static function cleanURL(string $url): string public static function cleanURL(string $url)
{ {
$url = trim($url, '/'); $url = trim($url, '/');
$url = str_replace('/index.php', '', $url); $url = str_replace('/index.php', '', $url);
@ -305,7 +305,7 @@ class GServer
* @param string $url * @param string $url
* @return string base URL * @return string base URL
*/ */
private static function getBaseURL(string $url): string private static function getBaseURL(string $url)
{ {
$urlparts = parse_url(self::cleanURL($url)); $urlparts = parse_url(self::cleanURL($url));
unset($urlparts['path']); unset($urlparts['path']);
@ -322,7 +322,7 @@ class GServer
* *
* @return boolean 'true' if server could be detected * @return boolean 'true' if server could be detected
*/ */
public static function detect(string $url, string $network = '', bool $only_nodeinfo = false): bool public static function detect(string $url, string $network = '', bool $only_nodeinfo = false)
{ {
Logger::info('Detect server type', ['server' => $url]); Logger::info('Detect server type', ['server' => $url]);
$serverdata = ['detection-method' => self::DETECT_MANUAL]; $serverdata = ['detection-method' => self::DETECT_MANUAL];
@ -535,7 +535,7 @@ class GServer
$serverdata['last_contact'] = DateTimeFormat::utcNow(); $serverdata['last_contact'] = DateTimeFormat::utcNow();
$serverdata['failed'] = false; $serverdata['failed'] = false;
$gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => $serverdata['nurl']]); $gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => Strings::normaliseLink($url)]);
if (!DBA::isResult($gserver)) { if (!DBA::isResult($gserver)) {
$serverdata['created'] = DateTimeFormat::utcNow(); $serverdata['created'] = DateTimeFormat::utcNow();
$ret = DBA::insert('gserver', $serverdata); $ret = DBA::insert('gserver', $serverdata);
@ -586,7 +586,6 @@ class GServer
* Fetch relay data from a given server url * Fetch relay data from a given server url
* *
* @param string $server_url address of the server * @param string $server_url address of the server
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function discoverRelay(string $server_url) private static function discoverRelay(string $server_url)
@ -686,7 +685,7 @@ class GServer
* *
* @return array server data * @return array server data
*/ */
private static function fetchStatistics(string $url): array private static function fetchStatistics(string $url)
{ {
$curlResult = DI::httpClient()->get($url . '/statistics.json', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/statistics.json', HttpClientAccept::JSON);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
@ -759,7 +758,7 @@ class GServer
* @return array Server data * @return array Server data
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function fetchNodeinfo(string $url, ICanHandleHttpResponses $httpResult): array private static function fetchNodeinfo(string $url, ICanHandleHttpResponses $httpResult)
{ {
if (!$httpResult->isSuccess()) { if (!$httpResult->isSuccess()) {
return []; return [];
@ -812,7 +811,7 @@ class GServer
* @return array Server data * @return array Server data
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function parseNodeinfo1(string $nodeinfo_url): array private static function parseNodeinfo1(string $nodeinfo_url)
{ {
$curlResult = DI::httpClient()->get($nodeinfo_url, HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($nodeinfo_url, HttpClientAccept::JSON);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
@ -905,7 +904,7 @@ class GServer
* @return array Server data * @return array Server data
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function parseNodeinfo2(string $nodeinfo_url): array private static function parseNodeinfo2(string $nodeinfo_url)
{ {
$curlResult = DI::httpClient()->get($nodeinfo_url, HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($nodeinfo_url, HttpClientAccept::JSON);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
@ -1002,9 +1001,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function fetchSiteinfo(string $url, array $serverdata): array private static function fetchSiteinfo(string $url, array $serverdata)
{ {
$curlResult = DI::httpClient()->get($url . '/siteinfo.json', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/siteinfo.json', HttpClientAccept::JSON);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
@ -1085,9 +1085,10 @@ class GServer
* Checks if the server contains a valid host meta file * Checks if the server contains a valid host meta file
* *
* @param string $url URL of the given server * @param string $url URL of the given server
*
* @return boolean 'true' if the server seems to be vital * @return boolean 'true' if the server seems to be vital
*/ */
private static function validHostMeta(string $url): bool private static function validHostMeta(string $url)
{ {
$xrd_timeout = DI::config()->get('system', 'xrd_timeout'); $xrd_timeout = DI::config()->get('system', 'xrd_timeout');
$curlResult = DI::httpClient()->get($url . '/.well-known/host-meta', HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout]); $curlResult = DI::httpClient()->get($url . '/.well-known/host-meta', HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout]);
@ -1130,9 +1131,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function detectNetworkViaContacts(string $url, array $serverdata): array private static function detectNetworkViaContacts(string $url, array $serverdata)
{ {
$contacts = []; $contacts = [];
@ -1174,9 +1176,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function checkPoCo(string $url, array $serverdata): array private static function checkPoCo(string $url, array $serverdata)
{ {
$serverdata['poco'] = ''; $serverdata['poco'] = '';
@ -1205,9 +1208,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
public static function checkMastodonDirectory(string $url, array $serverdata): array public static function checkMastodonDirectory(string $url, array $serverdata)
{ {
$curlResult = DI::httpClient()->get($url . '/api/v1/directory?limit=1', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/api/v1/directory?limit=1', HttpClientAccept::JSON);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
@ -1234,7 +1238,7 @@ class GServer
* *
* @return array server data * @return array server data
*/ */
private static function detectPeertube(string $url, array $serverdata): array private static function detectPeertube(string $url, array $serverdata)
{ {
$curlResult = DI::httpClient()->get($url . '/api/v1/config', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/api/v1/config', HttpClientAccept::JSON);
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
@ -1278,9 +1282,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function detectNextcloud(string $url, array $serverdata): array private static function detectNextcloud(string $url, array $serverdata)
{ {
$curlResult = DI::httpClient()->get($url . '/status.php', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/status.php', HttpClientAccept::JSON);
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
@ -1305,15 +1310,7 @@ class GServer
return $serverdata; return $serverdata;
} }
/** private static function fetchWeeklyUsage(string $url, array $serverdata) {
* Fetches weekly usage data
*
* @param string $url URL of the given server
* @param array $serverdata array with server data
* @return array server data
*/
private static function fetchWeeklyUsage(string $url, array $serverdata): array
{
$curlResult = DI::httpClient()->get($url . '/api/v1/instance/activity', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/api/v1/instance/activity', HttpClientAccept::JSON);
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
return $serverdata; return $serverdata;
@ -1349,9 +1346,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function detectFromContacts(string $url, array $serverdata): array private static function detectFromContacts(string $url, array $serverdata)
{ {
$gserver = DBA::selectFirst('gserver', ['id'], ['nurl' => Strings::normaliseLink($url)]); $gserver = DBA::selectFirst('gserver', ['id'], ['nurl' => Strings::normaliseLink($url)]);
if (empty($gserver)) { if (empty($gserver)) {
@ -1376,9 +1374,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function detectMastodonAlikes(string $url, array $serverdata): array private static function detectMastodonAlikes(string $url, array $serverdata)
{ {
$curlResult = DI::httpClient()->get($url . '/api/v1/instance', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/api/v1/instance', HttpClientAccept::JSON);
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
@ -1440,9 +1439,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function detectHubzilla(string $url, array $serverdata): array private static function detectHubzilla(string $url, array $serverdata)
{ {
$curlResult = DI::httpClient()->get($url . '/api/statusnet/config.json', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/api/statusnet/config.json', HttpClientAccept::JSON);
if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) { if (!$curlResult->isSuccess() || ($curlResult->getBody() == '')) {
@ -1517,9 +1517,10 @@ class GServer
* Converts input value to a boolean value * Converts input value to a boolean value
* *
* @param string|integer $val * @param string|integer $val
*
* @return boolean * @return boolean
*/ */
private static function toBoolean($val): bool private static function toBoolean($val)
{ {
if (($val == 'true') || ($val == 1)) { if (($val == 'true') || ($val == 1)) {
return true; return true;
@ -1535,9 +1536,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function detectPumpIO(string $url, array $serverdata): array private static function detectPumpIO(string $url, array $serverdata)
{ {
$curlResult = DI::httpClient()->get($url . '/.well-known/host-meta.json', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/.well-known/host-meta.json', HttpClientAccept::JSON);
if (!$curlResult->isSuccess()) { if (!$curlResult->isSuccess()) {
@ -1547,6 +1549,7 @@ class GServer
$data = json_decode($curlResult->getBody(), true); $data = json_decode($curlResult->getBody(), true);
if (empty($data['links'])) { if (empty($data['links'])) {
return $serverdata; return $serverdata;
} }
// We are looking for some endpoints that are typical for pump.io // We are looking for some endpoints that are typical for pump.io
@ -1583,9 +1586,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function detectGNUSocial(string $url, array $serverdata): array private static function detectGNUSocial(string $url, array $serverdata)
{ {
// Test for GNU Social // Test for GNU Social
$curlResult = DI::httpClient()->get($url . '/api/gnusocial/version.json', HttpClientAccept::JSON); $curlResult = DI::httpClient()->get($url . '/api/gnusocial/version.json', HttpClientAccept::JSON);
@ -1637,9 +1641,10 @@ class GServer
* *
* @param string $url URL of the given server * @param string $url URL of the given server
* @param array $serverdata array with server data * @param array $serverdata array with server data
*
* @return array server data * @return array server data
*/ */
private static function detectFriendica(string $url, array $serverdata): array private static function detectFriendica(string $url, array $serverdata)
{ {
// There is a bug in some versions of Friendica that will return an ActivityStream actor when the content type "application/json" is requested. // There is a bug in some versions of Friendica that will return an ActivityStream actor when the content type "application/json" is requested.
// Because of this me must not use ACCEPT_JSON here. // Because of this me must not use ACCEPT_JSON here.
@ -1712,9 +1717,10 @@ class GServer
* @param object $curlResult result of curl execution * @param object $curlResult result of curl execution
* @param array $serverdata array with server data * @param array $serverdata array with server data
* @param string $url Server URL * @param string $url Server URL
*
* @return array server data * @return array server data
*/ */
private static function analyseRootBody($curlResult, array $serverdata, string $url): array private static function analyseRootBody($curlResult, array $serverdata, string $url)
{ {
if (empty($curlResult->getBody())) { if (empty($curlResult->getBody())) {
return $serverdata; return $serverdata;
@ -1853,7 +1859,7 @@ class GServer
* *
* @return array server data * @return array server data
*/ */
private static function analyseRootHeader($curlResult, array $serverdata): array private static function analyseRootHeader($curlResult, array $serverdata)
{ {
if ($curlResult->getHeader('server') == 'Mastodon') { if ($curlResult->getHeader('server') == 'Mastodon') {
$serverdata['platform'] = 'mastodon'; $serverdata['platform'] = 'mastodon';
@ -2048,7 +2054,7 @@ class GServer
* @return int * @return int
* @throws Exception * @throws Exception
*/ */
public static function getProtocol(int $gsid): int public static function getProtocol(int $gsid)
{ {
if (empty($gsid)) { if (empty($gsid)) {
return null; return null;

View file

@ -39,14 +39,7 @@ class Group
const FOLLOWERS = '~'; const FOLLOWERS = '~';
const MUTUALS = '&'; const MUTUALS = '&';
/** public static function getByUserId($uid, $includesDeleted = false)
* Fetches group record by user id and maybe includes deleted groups as well
*
* @param int $uid User id to fetch group(s) for
* @param bool $includesDeleted Whether deleted groups should be included
* @return array|bool Array on success, bool on error
*/
public static function getByUserId(int $uid, bool $includesDeleted = false)
{ {
$conditions = ['uid' => $uid, 'cid' => null]; $conditions = ['uid' => $uid, 'cid' => null];
@ -58,18 +51,15 @@ class Group
} }
/** /**
* Checks whether given group id is found in database * @param int $group_id
*
* @param int $group_id Groupd it
* @param int $uid Optional user id
* @return bool * @return bool
* @throws \Exception * @throws \Exception
*/ */
public static function exists(int $group_id, int $uid = null): bool public static function exists($group_id, $uid = null)
{ {
$condition = ['id' => $group_id, 'deleted' => false]; $condition = ['id' => $group_id, 'deleted' => false];
if (!is_null($uid)) { if (isset($uid)) {
$condition = [ $condition = [
'uid' => $uid 'uid' => $uid
]; ];
@ -83,12 +73,12 @@ class Group
* *
* Note: If we found a deleted group with the same name, we restore it * Note: If we found a deleted group with the same name, we restore it
* *
* @param int $uid User id to create group for * @param int $uid
* @param string $name Name of group * @param string $name
* @return int|boolean Id of newly created group or false on error * @return boolean
* @throws \Exception * @throws \Exception
*/ */
public static function create(int $uid, string $name) public static function create($uid, $name)
{ {
$return = false; $return = false;
if (!empty($uid) && !empty($name)) { if (!empty($uid) && !empty($name)) {
@ -124,7 +114,7 @@ class Group
* @return bool Was the update successful? * @return bool Was the update successful?
* @throws \Exception * @throws \Exception
*/ */
public static function update(int $id, string $name): bool public static function update($id, $name)
{ {
return DBA::update('group', ['name' => $name], ['id' => $id]); return DBA::update('group', ['name' => $name], ['id' => $id]);
} }
@ -132,11 +122,11 @@ class Group
/** /**
* Get a list of group ids a contact belongs to * Get a list of group ids a contact belongs to
* *
* @param int $cid Contact id * @param int $cid
* @return array Group ids * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function getIdsByContactId(int $cid): array public static function getIdsByContactId($cid)
{ {
$return = []; $return = [];
@ -195,12 +185,12 @@ class Group
* *
* Returns false if no group has been found. * Returns false if no group has been found.
* *
* @param int $uid User id * @param int $uid
* @param string $name Group name * @param string $name
* @return int|boolean Groups' id number or false on error * @return int|boolean
* @throws \Exception * @throws \Exception
*/ */
public static function getIdByName(int $uid, string $name) public static function getIdByName($uid, $name)
{ {
if (!$uid || !strlen($name)) { if (!$uid || !strlen($name)) {
return false; return false;
@ -221,7 +211,7 @@ class Group
* @return boolean * @return boolean
* @throws \Exception * @throws \Exception
*/ */
public static function remove(int $gid): bool public static function remove($gid)
{ {
if (!$gid) { if (!$gid) {
return false; return false;
@ -324,14 +314,13 @@ class Group
* Adds contacts to a group * Adds contacts to a group
* *
* @param int $gid * @param int $gid
* @param array $contacts Array with contact ids * @param array $contacts
* @return void
* @throws \Exception * @throws \Exception
*/ */
public static function addMembers(int $gid, array $contacts) public static function addMembers(int $gid, array $contacts)
{ {
if (!$gid || !$contacts) { if (!$gid || !$contacts) {
return; return false;
} }
// @TODO Backward compatibility with user contacts, remove by version 2022.03 // @TODO Backward compatibility with user contacts, remove by version 2022.03
@ -353,9 +342,8 @@ class Group
/** /**
* Removes contacts from a group * Removes contacts from a group
* *
* @param int $gid Group id * @param int $gid
* @param array $contacts Contact ids * @param array $contacts
* @return bool
* @throws \Exception * @throws \Exception
*/ */
public static function removeMembers(int $gid, array $contacts) public static function removeMembers(int $gid, array $contacts)
@ -381,20 +369,19 @@ class Group
$contactIds[] = $cdata['user']; $contactIds[] = $cdata['user'];
} }
// Return status of deletion DBA::delete('group_member', ['gid' => $gid, 'contact-id' => $contactIds]);
return DBA::delete('group_member', ['gid' => $gid, 'contact-id' => $contactIds]);
} }
/** /**
* Returns the combined list of contact ids from a group id list * Returns the combined list of contact ids from a group id list
* *
* @param int $uid User id * @param int $uid
* @param array $group_ids Groups ids * @param array $group_ids
* @param boolean $check_dead Whether check "dead" records (?) * @param boolean $check_dead
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function expand(int $uid, array $group_ids, bool $check_dead = false): array public static function expand($uid, array $group_ids, $check_dead = false)
{ {
if (!is_array($group_ids) || !count($group_ids)) { if (!is_array($group_ids) || !count($group_ids)) {
return []; return [];
@ -467,13 +454,13 @@ class Group
/** /**
* Returns a templated group selection list * Returns a templated group selection list
* *
* @param int $uid User id * @param int $uid
* @param int $gid An optional pre-selected group * @param int $gid An optional pre-selected group
* @param string $label An optional label of the list * @param string $label An optional label of the list
* @return string * @return string
* @throws \Exception * @throws \Exception
*/ */
public static function displayGroupSelection(int $uid, int $gid = 0, string $label = ''): string public static function displayGroupSelection($uid, $gid = 0, $label = '')
{ {
$display_groups = [ $display_groups = [
[ [
@ -515,12 +502,12 @@ class Group
* 'standard' => include link 'Edit groups' * 'standard' => include link 'Edit groups'
* 'extended' => include link 'Create new group' * 'extended' => include link 'Create new group'
* 'full' => include link 'Create new group' and provide for each group a link to edit this group * 'full' => include link 'Create new group' and provide for each group a link to edit this group
* @param string|int $group_id Distinct group id or 'everyone' * @param string $group_id
* @param int $cid Contact id * @param int $cid
* @return string Sidebar widget HTML code * @return string
* @throws \Exception * @throws \Exception
*/ */
public static function sidebarWidget(string $every = 'contact', string $each = 'group', string $editmode = 'standard', $group_id = '', int $cid = 0) public static function sidebarWidget($every = 'contact', $each = 'group', $editmode = 'standard', $group_id = '', $cid = 0)
{ {
if (!local_user()) { if (!local_user()) {
return ''; return '';
@ -602,7 +589,7 @@ class Group
* @param integer $id Contact ID * @param integer $id Contact ID
* @return integer Group IO * @return integer Group IO
*/ */
public static function getIdForForum(int $id): int public static function getIdForForum(int $id)
{ {
Logger::info('Get id for forum id', ['id' => $id]); Logger::info('Get id for forum id', ['id' => $id]);
$contact = Contact::getById($id, ['uid', 'name', 'contact-type', 'manually-approve']); $contact = Contact::getById($id, ['uid', 'name', 'contact-type', 'manually-approve']);
@ -630,7 +617,6 @@ class Group
* Fetch the followers of a given contact id and store them as group members * Fetch the followers of a given contact id and store them as group members
* *
* @param integer $id Contact ID * @param integer $id Contact ID
* @return void
*/ */
public static function updateMembersForForum(int $id) public static function updateMembersForForum(int $id)
{ {

View file

@ -96,8 +96,8 @@ class Item
'event-created', 'event-edited', 'event-start', 'event-finish', 'event-created', 'event-edited', 'event-start', 'event-finish',
'event-summary', 'event-desc', 'event-location', 'event-type', 'event-summary', 'event-desc', 'event-location', 'event-type',
'event-nofinish', 'event-ignore', 'event-id', 'event-nofinish', 'event-ignore', 'event-id',
'question-id', 'question-multiple', 'question-voters', 'question-end-time', "question-id", "question-multiple", "question-voters", "question-end-time",
'has-categories', 'has-media', "has-categories", "has-media",
'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed' 'delivery_queue_count', 'delivery_queue_done', 'delivery_queue_failed'
]; ];
@ -226,7 +226,7 @@ class Item
foreach ($notify_items as $notify_item) { foreach ($notify_items as $notify_item) {
$post = Post::selectFirst(['uri-id', 'uid'], ['id' => $notify_item]); $post = Post::selectFirst(['uri-id', 'uid'], ['id' => $notify_item]);
Worker::add(PRIORITY_HIGH, 'Notifier', Delivery::POST, (int)$post['uri-id'], (int)$post['uid']); Worker::add(PRIORITY_HIGH, "Notifier", Delivery::POST, (int)$post['uri-id'], (int)$post['uid']);
} }
return $rows; return $rows;
@ -237,10 +237,9 @@ class Item
* *
* @param array $condition The condition for finding the item entries * @param array $condition The condition for finding the item entries
* @param integer $priority Priority for the notification * @param integer $priority Priority for the notification
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function markForDeletion(array $condition, int $priority = PRIORITY_HIGH) public static function markForDeletion($condition, $priority = PRIORITY_HIGH)
{ {
$items = Post::select(['id'], $condition); $items = Post::select(['id'], $condition);
while ($item = Post::fetch($items)) { while ($item = Post::fetch($items)) {
@ -254,10 +253,9 @@ class Item
* *
* @param array $condition The condition for finding the item entries * @param array $condition The condition for finding the item entries
* @param integer $uid User who wants to delete this item * @param integer $uid User who wants to delete this item
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function deleteForUser(array $condition, int $uid) public static function deleteForUser($condition, $uid)
{ {
if ($uid == 0) { if ($uid == 0) {
return; return;
@ -284,10 +282,11 @@ class Item
* *
* @param integer $item_id * @param integer $item_id
* @param integer $priority Priority for the notification * @param integer $priority Priority for the notification
*
* @return boolean success * @return boolean success
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function markForDeletionById(int $item_id, int $priority = PRIORITY_HIGH): bool public static function markForDeletionById($item_id, $priority = PRIORITY_HIGH)
{ {
Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]); Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]);
// locate item to be deleted // locate item to be deleted
@ -332,7 +331,7 @@ class Item
// If item has attachments, drop them // If item has attachments, drop them
$attachments = Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT]); $attachments = Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT]);
foreach($attachments as $attachment) { foreach($attachments as $attachment) {
if (preg_match('|attach/(\d+)|', $attachment['url'], $matches)) { if (preg_match("|attach/(\d+)|", $attachment['url'], $matches)) {
Attach::delete(['id' => $matches[1], 'uid' => $item['uid']]); Attach::delete(['id' => $matches[1], 'uid' => $item['uid']]);
} }
} }
@ -361,7 +360,7 @@ class Item
// send the notification upstream/downstream // send the notification upstream/downstream
if ($priority) { if ($priority) {
Worker::add(['priority' => $priority, 'dont_fork' => true], 'Notifier', Delivery::DELETION, (int)$item['uri-id'], (int)$item['uid']); Worker::add(['priority' => $priority, 'dont_fork' => true], "Notifier", Delivery::DELETION, (int)$item['uri-id'], (int)$item['uid']);
} }
} elseif ($item['uid'] != 0) { } elseif ($item['uid'] != 0) {
Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]); Post\User::update($item['uri-id'], $item['uid'], ['hidden' => true]);
@ -373,14 +372,7 @@ class Item
return true; return true;
} }
/** public static function guid($item, $notify)
* Get guid from given item record
*
* @param array $item Item record
* @param bool Whether to notify (?)
* @return string Guid
*/
public static function guid(array $item, bool $notify): string
{ {
if (!empty($item['guid'])) { if (!empty($item['guid'])) {
return trim($item['guid']); return trim($item['guid']);
@ -433,13 +425,7 @@ class Item
return $guid; return $guid;
} }
/** private static function contactId($item)
* Returns contact id from given item record
*
* @param array $item Item record
* @return int Contact id
*/
private static function contactId(array $item): int
{ {
if (!empty($item['contact-id']) && DBA::exists('contact', ['self' => true, 'id' => $item['contact-id']])) { if (!empty($item['contact-id']) && DBA::exists('contact', ['self' => true, 'id' => $item['contact-id']])) {
return $item['contact-id']; return $item['contact-id'];
@ -465,17 +451,17 @@ class Item
* @param array $item The item fields that are to be inserted * @param array $item The item fields that are to be inserted
* @throws \Exception * @throws \Exception
*/ */
private static function spool(array $item) private static function spool($orig_item)
{ {
// Now we store the data in the spool directory // Now we store the data in the spool directory
// We use "microtime" to keep the arrival order and "mt_rand" to avoid duplicates // We use "microtime" to keep the arrival order and "mt_rand" to avoid duplicates
$file = 'item-' . round(microtime(true) * 10000) . '-' . mt_rand() . '.msg'; $file = 'item-' . round(microtime(true) * 10000) . '-' . mt_rand() . '.msg';
$spoolpath = System::getSpoolPath(); $spoolpath = System::getSpoolPath();
if ($spoolpath != '') { if ($spoolpath != "") {
$spool = $spoolpath . '/' . $file; $spool = $spoolpath . '/' . $file;
file_put_contents($spool, json_encode($item)); file_put_contents($spool, json_encode($orig_item));
Logger::warning("Item wasn't stored - Item was spooled into file", ['file' => $file]); Logger::warning("Item wasn't stored - Item was spooled into file", ['file' => $file]);
} }
} }
@ -483,10 +469,10 @@ class Item
/** /**
* Check if the item array is a duplicate * Check if the item array is a duplicate
* *
* @param array $item Item record * @param array $item
* @return boolean is it a duplicate? * @return boolean is it a duplicate?
*/ */
private static function isDuplicate(array $item): bool private static function isDuplicate(array $item)
{ {
// Checking if there is already an item with the same guid // Checking if there is already an item with the same guid
$condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']]; $condition = ['guid' => $item['guid'], 'network' => $item['network'], 'uid' => $item['uid']];
@ -535,10 +521,10 @@ class Item
/** /**
* Check if the item array is valid * Check if the item array is valid
* *
* @param array $item Item record * @param array $item
* @return boolean item is valid * @return boolean item is valid
*/ */
public static function isValid(array $item): bool public static function isValid(array $item)
{ {
// When there is no content then we don't post it // When there is no content then we don't post it
if (($item['body'] . $item['title'] == '') && (empty($item['uri-id']) || !Post\Media::existsByURIId($item['uri-id']))) { if (($item['body'] . $item['title'] == '') && (empty($item['uri-id']) || !Post\Media::existsByURIId($item['uri-id']))) {
@ -605,10 +591,10 @@ class Item
/** /**
* Check if the item array is too old * Check if the item array is too old
* *
* @param array $item Item record * @param array $item
* @return boolean item is too old * @return boolean item is too old
*/ */
public static function isTooOld(array $item): bool public static function isTooOld(array $item)
{ {
// check for create date and expire time // check for create date and expire time
$expire_interval = DI::config()->get('system', 'dbclean-expire-days', 0); $expire_interval = DI::config()->get('system', 'dbclean-expire-days', 0);
@ -637,20 +623,15 @@ class Item
/** /**
* Return the id of the given item array if it has been stored before * Return the id of the given item array if it has been stored before
* *
* @param array $item Item record * @param array $item
* @return integer Item id or zero on error * @return integer item id
*/ */
private static function getDuplicateID(array $item): int private static function getDuplicateID(array $item)
{ {
if (empty($item['network']) || in_array($item['network'], Protocol::FEDERATED)) { if (empty($item['network']) || in_array($item['network'], Protocol::FEDERATED)) {
$condition = ['`uri-id` = ? AND `uid` = ? AND `network` IN (?, ?, ?, ?)', $condition = ["`uri-id` = ? AND `uid` = ? AND `network` IN (?, ?, ?, ?)",
$item['uri-id'], $item['uri-id'], $item['uid'],
$item['uid'], Protocol::ACTIVITYPUB, Protocol::DIASPORA, Protocol::DFRN, Protocol::OSTATUS];
Protocol::ACTIVITYPUB,
Protocol::DIASPORA,
Protocol::DFRN,
Protocol::OSTATUS
];
$existing = Post::selectFirst(['id', 'network'], $condition); $existing = Post::selectFirst(['id', 'network'], $condition);
if (DBA::isResult($existing)) { if (DBA::isResult($existing)) {
// We only log the entries with a different user id than 0. Otherwise we would have too many false positives // We only log the entries with a different user id than 0. Otherwise we would have too many false positives
@ -659,12 +640,12 @@ class Item
'uri-id' => $item['uri-id'], 'uri-id' => $item['uri-id'],
'uid' => $item['uid'], 'uid' => $item['uid'],
'network' => $item['network'], 'network' => $item['network'],
'existing_id' => $existing['id'], 'existing_id' => $existing["id"],
'existing_network' => $existing['network'] 'existing_network' => $existing["network"]
]); ]);
} }
return $existing['id']; return $existing["id"];
} }
} }
return 0; return 0;
@ -677,7 +658,7 @@ class Item
* @return array item array with parent data * @return array item array with parent data
* @throws \Exception * @throws \Exception
*/ */
private static function getTopLevelParent(array $item): array private static function getTopLevelParent(array $item)
{ {
$fields = ['uid', 'uri', 'parent-uri', 'id', 'deleted', $fields = ['uid', 'uri', 'parent-uri', 'id', 'deleted',
'uri-id', 'parent-uri-id', 'uri-id', 'parent-uri-id',
@ -728,7 +709,7 @@ class Item
* @param array $item * @param array $item
* @return integer gravity * @return integer gravity
*/ */
private static function getGravity(array $item): int private static function getGravity(array $item)
{ {
$activity = DI::activity(); $activity = DI::activity();
@ -743,20 +724,11 @@ class Item
} elseif ($activity->match($item['verb'], Activity::ANNOUNCE)) { } elseif ($activity->match($item['verb'], Activity::ANNOUNCE)) {
return GRAVITY_ACTIVITY; return GRAVITY_ACTIVITY;
} }
Logger::info('Unknown gravity for verb', ['verb' => $item['verb']]); Logger::info('Unknown gravity for verb', ['verb' => $item['verb']]);
return GRAVITY_UNKNOWN; // Should not happen return GRAVITY_UNKNOWN; // Should not happen
} }
/** public static function insert(array $item, int $notify = 0, bool $post_local = true)
* Inserts item record
*
* @param array $item Item array to be inserted
* @param int $notify Notification (type?)
* @param bool $post_local (???)
* @return int Zero means error, otherwise primary key (id) is being returned
*/
public static function insert(array $item, int $notify = 0, bool $post_local = true): int
{ {
$orig_item = $item; $orig_item = $item;
@ -897,7 +869,7 @@ class Item
Contact::checkAvatarCache($item['owner-id']); Contact::checkAvatarCache($item['owner-id']);
// The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes // The contact-id should be set before "self::insert" was called - but there seems to be issues sometimes
$item['contact-id'] = self::contactId($item); $item["contact-id"] = self::contactId($item);
if (!empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) && if (!empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) &&
empty($item['origin']) &&self::isTooOld($item)) { empty($item['origin']) &&self::isTooOld($item)) {
@ -972,8 +944,8 @@ class Item
$item['thr-parent-id'] = ItemURI::getIdByURI($item['thr-parent']); $item['thr-parent-id'] = ItemURI::getIdByURI($item['thr-parent']);
// Is this item available in the global items (with uid=0)? // Is this item available in the global items (with uid=0)?
if ($item['uid'] == 0) { if ($item["uid"] == 0) {
$item['global'] = true; $item["global"] = true;
// Set the global flag on all items if this was a global item entry // Set the global flag on all items if this was a global item entry
Post::update(['global' => true], ['uri-id' => $item['uri-id']]); Post::update(['global' => true], ['uri-id' => $item['uri-id']]);
@ -982,8 +954,8 @@ class Item
} }
// ACL settings // ACL settings
if (!empty($item['allow_cid'] . $item['allow_gid'] . $item['deny_cid'] . $item['deny_gid'])) { if (!empty($item["allow_cid"] . $item["allow_gid"] . $item["deny_cid"] . $item["deny_gid"])) {
$item['private'] = self::PRIVATE; $item["private"] = self::PRIVATE;
} }
if ($notify && $post_local) { if ($notify && $post_local) {
@ -1351,7 +1323,7 @@ class Item
* @param string $signed_text Original text (for Diaspora signatures), JSON encoded. * @param string $signed_text Original text (for Diaspora signatures), JSON encoded.
* @throws \Exception * @throws \Exception
*/ */
public static function distribute(int $itemid, string $signed_text = '') public static function distribute($itemid, $signed_text = '')
{ {
$condition = ["`id` IN (SELECT `parent` FROM `post-user-view` WHERE `id` = ?)", $itemid]; $condition = ["`id` IN (SELECT `parent` FROM `post-user-view` WHERE `id` = ?)", $itemid];
$parent = Post::selectFirst(['owner-id'], $condition); $parent = Post::selectFirst(['owner-id'], $condition);
@ -1445,7 +1417,7 @@ class Item
* @param integer $source_uid User id of the source post * @param integer $source_uid User id of the source post
* @return integer stored item id * @return integer stored item id
*/ */
public static function storeForUserByUriId(int $uri_id, int $uid, array $fields = [], int $source_uid = 0): int public static function storeForUserByUriId(int $uri_id, int $uid, array $fields = [], int $source_uid = 0)
{ {
if ($uid == $source_uid) { if ($uid == $source_uid) {
Logger::warning('target UID must not be be equal to the source UID', ['uri-id' => $uri_id, 'uid' => $uid]); Logger::warning('target UID must not be be equal to the source UID', ['uri-id' => $uri_id, 'uid' => $uid]);
@ -1553,7 +1525,7 @@ class Item
* @return integer stored item id * @return integer stored item id
* @throws \Exception * @throws \Exception
*/ */
private static function storeForUser(array $item, int $uid): int private static function storeForUser(array $item, int $uid)
{ {
if (Post::exists(['uri-id' => $item['uri-id'], 'uid' => $uid])) { if (Post::exists(['uri-id' => $item['uri-id'], 'uid' => $uid])) {
if (!empty($item['event-id'])) { if (!empty($item['event-id'])) {
@ -1641,7 +1613,7 @@ class Item
* @param integer $itemid Item ID that should be added * @param integer $itemid Item ID that should be added
* @throws \Exception * @throws \Exception
*/ */
private static function addShadow(int $itemid) private static function addShadow($itemid)
{ {
$fields = ['uid', 'private', 'visible', 'deleted', 'network', 'uri-id']; $fields = ['uid', 'private', 'visible', 'deleted', 'network', 'uri-id'];
$condition = ['id' => $itemid, 'gravity' => GRAVITY_PARENT]; $condition = ['id' => $itemid, 'gravity' => GRAVITY_PARENT];
@ -1704,7 +1676,7 @@ class Item
* @param integer $itemid Item ID that should be added * @param integer $itemid Item ID that should be added
* @throws \Exception * @throws \Exception
*/ */
private static function addShadowPost(int $itemid) private static function addShadowPost($itemid)
{ {
$item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]); $item = Post::selectFirst(self::ITEM_FIELDLIST, ['id' => $itemid]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
@ -1768,7 +1740,7 @@ class Item
* @return string detected language * @return string detected language
* @throws \Text_LanguageDetect_Exception * @throws \Text_LanguageDetect_Exception
*/ */
private static function getLanguage(array $item): string private static function getLanguage(array $item)
{ {
if (!empty($item['language'])) { if (!empty($item['language'])) {
return $item['language']; return $item['language'];
@ -1812,7 +1784,7 @@ class Item
return ''; return '';
} }
public static function getLanguageMessage(array $item): string public static function getLanguageMessage(array $item)
{ {
$iso639 = new \Matriphe\ISO639\ISO639; $iso639 = new \Matriphe\ISO639\ISO639;
@ -1834,7 +1806,7 @@ class Item
* @param string $host hostname for the GUID prefix * @param string $host hostname for the GUID prefix
* @return string unique guid * @return string unique guid
*/ */
public static function guidFromUri(string $uri, string $host): string public static function guidFromUri($uri, $host)
{ {
// Our regular guid routine is using this kind of prefix as well // Our regular guid routine is using this kind of prefix as well
// We have to avoid that different routines could accidentally create the same value // We have to avoid that different routines could accidentally create the same value
@ -1878,7 +1850,7 @@ class Item
* @param array $arr Contains the just posted item record * @param array $arr Contains the just posted item record
* @throws \Exception * @throws \Exception
*/ */
private static function updateContact(array $arr) private static function updateContact($arr)
{ {
// Unarchive the author // Unarchive the author
$contact = DBA::selectFirst('contact', [], ['id' => $arr["author-id"]]); $contact = DBA::selectFirst('contact', [], ['id' => $arr["author-id"]]);
@ -1925,7 +1897,7 @@ class Item
} }
} }
public static function setHashtags(string $body): string public static function setHashtags($body)
{ {
$body = BBCode::performWithEscapedTags($body, ['noparse', 'pre', 'code', 'img'], function ($body) { $body = BBCode::performWithEscapedTags($body, ['noparse', 'pre', 'code', 'img'], function ($body) {
$tags = BBCode::getTags($body); $tags = BBCode::getTags($body);
@ -1999,7 +1971,7 @@ class Item
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function tagDeliver(int $uid, int $item_id): bool private static function tagDeliver($uid, $item_id)
{ {
$mention = false; $mention = false;
@ -2094,7 +2066,7 @@ class Item
self::performActivity($item['id'], 'announce', $item['uid']); self::performActivity($item['id'], 'announce', $item['uid']);
} }
public static function isRemoteSelf(array $contact, array &$datarray): bool public static function isRemoteSelf($contact, &$datarray)
{ {
if (!$contact['remote_self']) { if (!$contact['remote_self']) {
return false; return false;
@ -2188,7 +2160,7 @@ class Item
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function fixPrivatePhotos(string $s, int $uid, array $item = null, int $cid = 0): string public static function fixPrivatePhotos($s, $uid, $item = null, $cid = 0)
{ {
if (DI::config()->get('system', 'disable_embedded')) { if (DI::config()->get('system', 'disable_embedded')) {
return $s; return $s;
@ -2282,14 +2254,13 @@ class Item
return $new_body; return $new_body;
} }
private static function hasPermissions(array $obj) private static function hasPermissions($obj)
{ {
return !empty($obj['allow_cid']) || !empty($obj['allow_gid']) || return !empty($obj['allow_cid']) || !empty($obj['allow_gid']) ||
!empty($obj['deny_cid']) || !empty($obj['deny_gid']); !empty($obj['deny_cid']) || !empty($obj['deny_gid']);
} }
// @TODO $uid is unused parameter private static function samePermissions($uid, $obj1, $obj2)
private static function samePermissions($uid, array $obj1, array $obj2): bool
{ {
// first part is easy. Check that these are exactly the same. // first part is easy. Check that these are exactly the same.
if (($obj1['allow_cid'] == $obj2['allow_cid']) if (($obj1['allow_cid'] == $obj2['allow_cid'])
@ -2317,7 +2288,7 @@ class Item
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function enumeratePermissions(array $obj, bool $check_dead = false): array public static function enumeratePermissions(array $obj, bool $check_dead = false)
{ {
$aclFormater = DI::aclFormatter(); $aclFormater = DI::aclFormatter();
@ -2405,7 +2376,7 @@ class Item
Logger::notice('User ' . $uid . ": expired $expired items; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos"); Logger::notice('User ' . $uid . ": expired $expired items; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos");
} }
public static function firstPostDate(int $uid, bool $wall = false) public static function firstPostDate($uid, $wall = false)
{ {
$user = User::getById($uid, ['register_date']); $user = User::getById($uid, ['register_date']);
if (empty($user)) { if (empty($user)) {
@ -2446,7 +2417,7 @@ class Item
* array $arr * array $arr
* 'post_id' => ID of posted item * 'post_id' => ID of posted item
*/ */
public static function performActivity(int $item_id, string $verb, int $uid, string $allow_cid = null, string $allow_gid = null, string $deny_cid = null, string $deny_gid = null): bool public static function performActivity(int $item_id, string $verb, int $uid, string $allow_cid = null, string $allow_gid = null, string $deny_cid = null, string $deny_gid = null)
{ {
if (empty($uid)) { if (empty($uid)) {
return false; return false;
@ -2640,7 +2611,7 @@ class Item
* @param integer $owner_id User ID for which the permissions should be fetched * @param integer $owner_id User ID for which the permissions should be fetched
* @return array condition * @return array condition
*/ */
public static function getPermissionsConditionArrayByUserId(int $owner_id): array public static function getPermissionsConditionArrayByUserId(int $owner_id)
{ {
$local_user = local_user(); $local_user = local_user();
$remote_user = Session::getRemoteContactID($owner_id); $remote_user = Session::getRemoteContactID($owner_id);
@ -2672,7 +2643,7 @@ class Item
* @param string $table * @param string $table
* @return string * @return string
*/ */
public static function getPermissionsSQLByUserId(int $owner_id, string $table = ''): string public static function getPermissionsSQLByUserId(int $owner_id, string $table = '')
{ {
$local_user = local_user(); $local_user = local_user();
$remote_user = Session::getRemoteContactID($owner_id); $remote_user = Session::getRemoteContactID($owner_id);
@ -2720,7 +2691,7 @@ class Item
* @param \Friendica\Core\L10n $l10n * @param \Friendica\Core\L10n $l10n
* @return string * @return string
*/ */
public static function postType(array $item, \Friendica\Core\L10n $l10n): string public static function postType(array $item, \Friendica\Core\L10n $l10n)
{ {
if (!empty($item['event-id'])) { if (!empty($item['event-id'])) {
return $l10n->t('event'); return $l10n->t('event');
@ -2786,10 +2757,10 @@ class Item
* Given an item array, convert the body element from bbcode to html and add smilie icons. * Given an item array, convert the body element from bbcode to html and add smilie icons.
* If attach is true, also add icons for item attachments. * If attach is true, also add icons for item attachments.
* *
* @param array $item Record from item table * @param array $item
* @param boolean $attach If true, add icons for item attachments as well * @param boolean $attach
* @param boolean $is_preview Whether this is a preview * @param boolean $is_preview
* @param boolean $only_cache Whether only cached HTML should be updated * @param boolean $only_cache
* @return string item body html * @return string item body html
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
@ -2798,7 +2769,7 @@ class Item
* @hook prepare_body ('item'=>item array, 'html'=>body string, 'is_preview'=>boolean, 'filter_reasons'=>string array) after first bbcode to html * @hook prepare_body ('item'=>item array, 'html'=>body string, 'is_preview'=>boolean, 'filter_reasons'=>string array) after first bbcode to html
* @hook prepare_body_final ('item'=>item array, 'html'=>body string) after attach icons and blockquote special case handling (spoiler, author) * @hook prepare_body_final ('item'=>item array, 'html'=>body string) after attach icons and blockquote special case handling (spoiler, author)
*/ */
public static function prepareBody(array &$item, bool $attach = false, bool $is_preview = false, bool $only_cache = false): string public static function prepareBody(array &$item, $attach = false, $is_preview = false, $only_cache = false)
{ {
$a = DI::app(); $a = DI::app();
Hook::callAll('prepare_body_init', $item); Hook::callAll('prepare_body_init', $item);
@ -2840,7 +2811,7 @@ class Item
$s = $item["rendered-html"]; $s = $item["rendered-html"];
if ($only_cache) { if ($only_cache) {
return ''; return;
} }
// Compile eventual content filter reasons // Compile eventual content filter reasons
@ -2920,7 +2891,7 @@ class Item
* @param int $type * @param int $type
* @return bool * @return bool
*/ */
public static function containsLink(string $body, string $url, int $type = 0): bool public static function containsLink(string $body, string $url, int $type = 0)
{ {
// Make sure that for example site parameters aren't used when testing if the link is contained in the body // Make sure that for example site parameters aren't used when testing if the link is contained in the body
$urlparts = parse_url($url); $urlparts = parse_url($url);
@ -2953,7 +2924,7 @@ class Item
* @param string $body * @param string $body
* @return string modified body * @return string modified body
*/ */
private static function replaceVisualAttachments(array $attachments, string $body): string private static function replaceVisualAttachments(array $attachments, string $body)
{ {
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
@ -2984,7 +2955,7 @@ class Item
* @param string $content * @param string $content
* @return string modified content * @return string modified content
*/ */
private static function addVisualAttachments(array $attachments, array $item, string $content, bool $shared): string private static function addVisualAttachments(array $attachments, array $item, string $content, bool $shared)
{ {
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
$leading = ''; $leading = '';
@ -3076,7 +3047,7 @@ class Item
* @param array $ignore_links A list of URLs to ignore * @param array $ignore_links A list of URLs to ignore
* @return string modified content * @return string modified content
*/ */
private static function addLinkAttachment(int $uriid, array $attachments, string $body, string $content, bool $shared, array $ignore_links): string private static function addLinkAttachment(int $uriid, array $attachments, string $body, string $content, bool $shared, array $ignore_links)
{ {
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
// Don't show a preview when there is a visual attachment (audio or video) // Don't show a preview when there is a visual attachment (audio or video)
@ -3190,7 +3161,7 @@ class Item
* @param string $content * @param string $content
* @return string modified content * @return string modified content
*/ */
private static function addNonVisualAttachments(array $attachments, array $item, string $content): string private static function addNonVisualAttachments(array $attachments, array $item, string $content)
{ {
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
$trailing = ''; $trailing = '';
@ -3222,7 +3193,7 @@ class Item
return $content; return $content;
} }
private static function addQuestions(array $item, string $content): string private static function addQuestions(array $item, string $content)
{ {
DI::profiler()->startRecording('rendering'); DI::profiler()->startRecording('rendering');
if (!empty($item['question-id'])) { if (!empty($item['question-id'])) {
@ -3273,7 +3244,7 @@ class Item
* @return boolean|array False if item has not plink, otherwise array('href'=>plink url, 'title'=>translated title) * @return boolean|array False if item has not plink, otherwise array('href'=>plink url, 'title'=>translated title)
* @throws \Exception * @throws \Exception
*/ */
public static function getPlink(array $item) public static function getPlink($item)
{ {
if (!empty($item['plink']) && Network::isValidHttpUrl($item['plink'])) { if (!empty($item['plink']) && Network::isValidHttpUrl($item['plink'])) {
$plink = $item['plink']; $plink = $item['plink'];
@ -3320,7 +3291,7 @@ class Item
* *
* @return boolean "true" when it is a forum post * @return boolean "true" when it is a forum post
*/ */
public static function isForumPost(int $uri_id): bool public static function isForumPost(int $uri_id)
{ {
foreach (Tag::getByURIId($uri_id, [Tag::EXCLUSIVE_MENTION]) as $tag) { foreach (Tag::getByURIId($uri_id, [Tag::EXCLUSIVE_MENTION]) as $tag) {
if (DBA::exists('contact', ['uid' => 0, 'nurl' => Strings::normaliseLink($tag['url']), 'contact-type' => Contact::TYPE_COMMUNITY])) { if (DBA::exists('contact', ['uid' => 0, 'nurl' => Strings::normaliseLink($tag['url']), 'contact-type' => Contact::TYPE_COMMUNITY])) {
@ -3338,7 +3309,7 @@ class Item
* *
* @return integer item id * @return integer item id
*/ */
public static function searchByLink(string $uri, int $uid = 0): int public static function searchByLink($uri, $uid = 0)
{ {
$ssl_uri = str_replace('http://', 'https://', $uri); $ssl_uri = str_replace('http://', 'https://', $uri);
$uris = [$uri, $ssl_uri, Strings::normaliseLink($uri)]; $uris = [$uri, $ssl_uri, Strings::normaliseLink($uri)];
@ -3363,7 +3334,7 @@ class Item
* *
* @return string URI * @return string URI
*/ */
public static function getURIByLink(string $uri): string public static function getURIByLink(string $uri)
{ {
$ssl_uri = str_replace('http://', 'https://', $uri); $ssl_uri = str_replace('http://', 'https://', $uri);
$uris = [$uri, $ssl_uri, Strings::normaliseLink($uri)]; $uris = [$uri, $ssl_uri, Strings::normaliseLink($uri)];
@ -3389,7 +3360,7 @@ class Item
* *
* @return integer item id * @return integer item id
*/ */
public static function fetchByLink(string $uri, int $uid = 0): int public static function fetchByLink(string $uri, int $uid = 0)
{ {
Logger::info('Trying to fetch link', ['uid' => $uid, 'uri' => $uri]); Logger::info('Trying to fetch link', ['uid' => $uid, 'uri' => $uri]);
$item_id = self::searchByLink($uri, $uid); $item_id = self::searchByLink($uri, $uid);
@ -3435,7 +3406,7 @@ class Item
* *
* @return array with share information * @return array with share information
*/ */
public static function getShareArray(array $item): array public static function getShareArray($item)
{ {
if (!preg_match("/(.*?)\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", $item['body'], $matches)) { if (!preg_match("/(.*?)\[share(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism", $item['body'], $matches)) {
return []; return [];
@ -3458,7 +3429,7 @@ class Item
* *
* @return array item array with data from the original item * @return array item array with data from the original item
*/ */
public static function addShareDataFromOriginal(array $item): array public static function addShareDataFromOriginal(array $item)
{ {
$shared = self::getShareArray($item); $shared = self::getShareArray($item);
if (empty($shared)) { if (empty($shared)) {
@ -3519,7 +3490,7 @@ class Item
* @return bool * @return bool
* @throws \Exception * @throws \Exception
*/ */
protected static function isAllowedByUser(array $item, int $user_id): bool protected static function isAllowedByUser(array $item, int $user_id)
{ {
if (!empty($item['author-id']) && Contact\User::isBlocked($item['author-id'], $user_id)) { if (!empty($item['author-id']) && Contact\User::isBlocked($item['author-id'], $user_id)) {
Logger::notice('Author is blocked by user', ['author-link' => $item['author-link'], 'uid' => $user_id, 'item-uri' => $item['uri']]); Logger::notice('Author is blocked by user', ['author-link' => $item['author-link'], 'uid' => $user_id, 'item-uri' => $item['uri']]);
@ -3551,7 +3522,7 @@ class Item
* @param array $item * @param array $item
* @return string body * @return string body
*/ */
public static function improveSharedDataInBody(array $item): string public static function improveSharedDataInBody(array $item)
{ {
$shared = BBCode::fetchShareAttributes($item['body']); $shared = BBCode::fetchShareAttributes($item['body']);
if (empty($shared['link'])) { if (empty($shared['link'])) {

View file

@ -30,6 +30,7 @@ class ItemURI
* Insert an item-uri record and return its id * Insert an item-uri record and return its id
* *
* @param array $fields Item-uri fields * @param array $fields Item-uri fields
*
* @return int|null item-uri id * @return int|null item-uri id
* @throws \Exception * @throws \Exception
*/ */
@ -60,15 +61,12 @@ class ItemURI
* Searched for an id of a given uri. Adds it, if not existing yet. * Searched for an id of a given uri. Adds it, if not existing yet.
* *
* @param string $uri * @param string $uri
*
* @return integer item-uri id * @return integer item-uri id
* @throws \Exception * @throws \Exception
*/ */
public static function getIdByURI(string $uri): int public static function getIdByURI($uri)
{ {
if (empty($uri)) {
return 0;
}
// If the URI gets too long we only take the first parts and hope for best // If the URI gets too long we only take the first parts and hope for best
$uri = substr($uri, 0, 255); $uri = substr($uri, 0, 255);
@ -84,10 +82,11 @@ class ItemURI
* Searched for an id of a given guid. * Searched for an id of a given guid.
* *
* @param string $guid * @param string $guid
*
* @return integer item-uri id * @return integer item-uri id
* @throws \Exception * @throws \Exception
*/ */
public static function getIdByGUID(string $guid): int public static function getIdByGUID($guid)
{ {
// If the GUID gets too long we only take the first parts and hope for best // If the GUID gets too long we only take the first parts and hope for best
$guid = substr($guid, 0, 255); $guid = substr($guid, 0, 255);

View file

@ -60,7 +60,7 @@ class ParsedLogIterator implements \Iterator
* @param string $filename File to open * @param string $filename File to open
* @return $this * @return $this
*/ */
public function open(string $filename): ParsedLogIterator public function open(string $filename)
{ {
$this->reader->open($filename); $this->reader->open($filename);
return $this; return $this;
@ -70,7 +70,7 @@ class ParsedLogIterator implements \Iterator
* @param int $limit Max num of lines to read * @param int $limit Max num of lines to read
* @return $this * @return $this
*/ */
public function withLimit(int $limit): ParsedLogIterator public function withLimit(int $limit)
{ {
$this->limit = $limit; $this->limit = $limit;
return $this; return $this;
@ -80,7 +80,7 @@ class ParsedLogIterator implements \Iterator
* @param array $filters filters per column * @param array $filters filters per column
* @return $this * @return $this
*/ */
public function withFilters(array $filters): ParsedLogIterator public function withFilters(array $filters)
{ {
$this->filters = $filters; $this->filters = $filters;
return $this; return $this;
@ -90,7 +90,7 @@ class ParsedLogIterator implements \Iterator
* @param string $search string to search to filter lines * @param string $search string to search to filter lines
* @return $this * @return $this
*/ */
public function withSearch(string $search): ParsedLogIterator public function withSearch(string $search)
{ {
$this->search = $search; $this->search = $search;
return $this; return $this;
@ -100,10 +100,10 @@ class ParsedLogIterator implements \Iterator
* Check if parsed log line match filters. * Check if parsed log line match filters.
* Always match if no filters are set. * Always match if no filters are set.
* *
* @param ParsedLogLine $parsedlogline ParsedLogLine instance * @param ParsedLogLine $parsedlogline
* @return bool Wether the parse log line matches * @return bool
*/ */
private function filter(ParsedLogLine $parsedlogline): bool private function filter($parsedlogline)
{ {
$match = true; $match = true;
foreach ($this->filters as $filter => $filtervalue) { foreach ($this->filters as $filter => $filtervalue) {
@ -126,7 +126,7 @@ class ParsedLogIterator implements \Iterator
* @param ParsedLogLine $parsedlogline * @param ParsedLogLine $parsedlogline
* @return bool * @return bool
*/ */
private function search(ParsedLogLine $parsedlogline): bool private function search($parsedlogline)
{ {
if ($this->search != "") { if ($this->search != "") {
return strstr($parsedlogline->logline, $this->search) !== false; return strstr($parsedlogline->logline, $this->search) !== false;

View file

@ -45,7 +45,7 @@ class Mail
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function insert(array $msg, bool $notification = true) public static function insert($msg, $notification = true)
{ {
if (!isset($msg['reply'])) { if (!isset($msg['reply'])) {
$msg['reply'] = DBA::exists('mail', ['parent-uri' => $msg['parent-uri']]); $msg['reply'] = DBA::exists('mail', ['parent-uri' => $msg['parent-uri']]);
@ -125,7 +125,7 @@ class Mail
* @return int * @return int
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function send(int $recipient = 0, string $body = '', string $subject = '', string $replyto = ''): int public static function send($recipient = 0, $body = '', $subject = '', $replyto = '')
{ {
$a = DI::app(); $a = DI::app();
@ -255,7 +255,7 @@ class Mail
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function sendWall(array $recipient = [], string $body = '', string $subject = '', string $replyto = ''): int public static function sendWall(array $recipient = [], $body = '', $subject = '', $replyto = '')
{ {
if (!$recipient) { if (!$recipient) {
return -1; return -1;

View file

@ -22,7 +22,6 @@
namespace Friendica\Model; namespace Friendica\Model;
use Friendica\Core\Addon; use Friendica\Core\Addon;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\DI; use Friendica\DI;
use stdClass; use stdClass;
@ -102,7 +101,7 @@ class Nodeinfo
* *
* @return array with supported services * @return array with supported services
*/ */
public static function getServices(): array public static function getServices()
{ {
$services = [ $services = [
'inbound' => [], 'inbound' => [],
@ -157,19 +156,9 @@ class Nodeinfo
return $services; return $services;
} }
/** public static function getOrganization($config)
* Gathers organization information and returns it as an array
*
* @param IManageConfigValues $config Configuration instance
* @return array Organization information
*/
public static function getOrganization(IManageConfigValues $config): array
{ {
$organization = [ $organization = ['name' => null, 'contact' => null, 'account' => null];
'name' => null,
'contact' => null,
'account' => null
];
if (!empty($config->get('config', 'admin_email'))) { if (!empty($config->get('config', 'admin_email'))) {
$adminList = explode(',', str_replace(' ', '', $config->get('config', 'admin_email'))); $adminList = explode(',', str_replace(' ', '', $config->get('config', 'admin_email')));

View file

@ -40,16 +40,16 @@ class OpenWebAuthToken
* @return boolean * @return boolean
* @throws \Exception * @throws \Exception
*/ */
public static function create(string $type, uid $uid, string $token, string $meta) public static function create($type, $uid, $token, $meta)
{ {
$fields = [ $fields = [
'type' => $type, "type" => $type,
'uid' => $uid, "uid" => $uid,
'token' => $token, "token" => $token,
'meta' => $meta, "meta" => $meta,
'created' => DateTimeFormat::utcNow() "created" => DateTimeFormat::utcNow()
]; ];
return DBA::insert('openwebauth-token', $fields); return DBA::insert("openwebauth-token", $fields);
} }
/** /**
@ -62,15 +62,15 @@ class OpenWebAuthToken
* @return string|boolean The meta enry or false if not found. * @return string|boolean The meta enry or false if not found.
* @throws \Exception * @throws \Exception
*/ */
public static function getMeta(string $type, int $uid, string $token) public static function getMeta($type, $uid, $token)
{ {
$condition = ['type' => $type, 'uid' => $uid, 'token' => $token]; $condition = ["type" => $type, "uid" => $uid, "token" => $token];
$entry = DBA::selectFirst('openwebauth-token', ['id', 'meta'], $condition); $entry = DBA::selectFirst("openwebauth-token", ["id", "meta"], $condition);
if (DBA::isResult($entry)) { if (DBA::isResult($entry)) {
DBA::delete('openwebauth-token', ['id' => $entry['id']]); DBA::delete("openwebauth-token", ["id" => $entry["id"]]);
return $entry['meta']; return $entry["meta"];
} }
return false; return false;
} }
@ -82,10 +82,10 @@ class OpenWebAuthToken
* @param string $interval SQL compatible time interval * @param string $interval SQL compatible time interval
* @throws \Exception * @throws \Exception
*/ */
public static function purge(string $type, string $interval) public static function purge($type, $interval)
{ {
$condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . ' - INTERVAL ' . $interval]; $condition = ["`type` = ? AND `created` < ?", $type, DateTimeFormat::utcNow() . " - INTERVAL " . $interval];
DBA::delete('openwebauth-token', $condition); DBA::delete("openwebauth-token", $condition);
} }
} }

View file

@ -94,7 +94,7 @@ class Photo
$fields = self::getFields(); $fields = self::getFields();
} }
return DBA::selectFirst('photo', $fields, $conditions, $params); return DBA::selectFirst("photo", $fields, $conditions, $params);
} }
/** /**
@ -110,10 +110,10 @@ class Photo
* @throws \Exception * @throws \Exception
* @see \Friendica\Database\DBA::select * @see \Friendica\Database\DBA::select
*/ */
public static function getPhotosForUser(int $uid, string $resourceid, array $conditions = [], array $params = []) public static function getPhotosForUser($uid, $resourceid, array $conditions = [], array $params = [])
{ {
$conditions['resource-id'] = $resourceid; $conditions["resource-id"] = $resourceid;
$conditions['uid'] = $uid; $conditions["uid"] = $uid;
return self::selectToArray([], $conditions, $params); return self::selectToArray([], $conditions, $params);
} }
@ -132,11 +132,11 @@ class Photo
* @throws \Exception * @throws \Exception
* @see \Friendica\Database\DBA::select * @see \Friendica\Database\DBA::select
*/ */
public static function getPhotoForUser(int $uid, $resourceid, $scale = 0, array $conditions = [], array $params = []) public static function getPhotoForUser($uid, $resourceid, $scale = 0, array $conditions = [], array $params = [])
{ {
$conditions['resource-id'] = $resourceid; $conditions["resource-id"] = $resourceid;
$conditions['uid'] = $uid; $conditions["uid"] = $uid;
$conditions['scale'] = $scale; $conditions["scale"] = $scale;
return self::selectFirst([], $conditions, $params); return self::selectFirst([], $conditions, $params);
} }
@ -156,19 +156,19 @@ class Photo
*/ */
public static function getPhoto(string $resourceid, int $scale = 0) public static function getPhoto(string $resourceid, int $scale = 0)
{ {
$r = self::selectFirst(['uid'], ['resource-id' => $resourceid]); $r = self::selectFirst(["uid"], ["resource-id" => $resourceid]);
if (!DBA::isResult($r)) { if (!DBA::isResult($r)) {
return false; return false;
} }
$uid = $r['uid']; $uid = $r["uid"];
$accessible = $uid ? (bool)DI::pConfig()->get($uid, 'system', 'accessible-photos', false) : false; $accessible = $uid ? (bool)DI::pConfig()->get($uid, 'system', 'accessible-photos', false) : false;
$sql_acl = Security::getPermissionsSQLByUserId($uid, $accessible); $sql_acl = Security::getPermissionsSQLByUserId($uid, $accessible);
$conditions = ["`resource-id` = ? AND `scale` <= ? " . $sql_acl, $resourceid, $scale]; $conditions = ["`resource-id` = ? AND `scale` <= ? " . $sql_acl, $resourceid, $scale];
$params = ['order' => ['scale' => true]]; $params = ["order" => ["scale" => true]];
$photo = self::selectFirst([], $conditions, $params); $photo = self::selectFirst([], $conditions, $params);
return $photo; return $photo;
@ -182,9 +182,9 @@ class Photo
* @return boolean * @return boolean
* @throws \Exception * @throws \Exception
*/ */
public static function exists(array $conditions): bool public static function exists(array $conditions)
{ {
return DBA::exists('photo', $conditions); return DBA::exists("photo", $conditions);
} }
@ -193,7 +193,7 @@ class Photo
* *
* @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref' * @param array $photo Photo data. Needs at least 'id', 'type', 'backend-class', 'backend-ref'
* *
* @return \Friendica\Object\Image|null Image object or null on error * @return \Friendica\Object\Image
*/ */
public static function getImageDataForPhoto(array $photo) public static function getImageDataForPhoto(array $photo)
{ {
@ -248,11 +248,11 @@ class Photo
* @return array field list * @return array field list
* @throws \Exception * @throws \Exception
*/ */
private static function getFields(): array private static function getFields()
{ {
$allfields = DBStructure::definition(DI::app()->getBasePath(), false); $allfields = DBStructure::definition(DI::app()->getBasePath(), false);
$fields = array_keys($allfields['photo']['fields']); $fields = array_keys($allfields["photo"]["fields"]);
array_splice($fields, array_search('data', $fields), 1); array_splice($fields, array_search("data", $fields), 1);
return $fields; return $fields;
} }
@ -265,14 +265,14 @@ class Photo
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function createPhotoForSystemResource(string $filename, string $mimetype = ''): array public static function createPhotoForSystemResource($filename, $mimetype = '')
{ {
if (empty($mimetype)) { if (empty($mimetype)) {
$mimetype = Images::guessTypeByExtension($filename); $mimetype = Images::guessTypeByExtension($filename);
} }
$fields = self::getFields(); $fields = self::getFields();
$values = array_fill(0, count($fields), ''); $values = array_fill(0, count($fields), "");
$photo = array_combine($fields, $values); $photo = array_combine($fields, $values);
$photo['backend-class'] = SystemResource::NAME; $photo['backend-class'] = SystemResource::NAME;
@ -293,14 +293,14 @@ class Photo
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function createPhotoForExternalResource(string $url, int $uid = 0, string $mimetype = ''): array public static function createPhotoForExternalResource($url, $uid = 0, $mimetype = '')
{ {
if (empty($mimetype)) { if (empty($mimetype)) {
$mimetype = Images::guessTypeByExtension($url); $mimetype = Images::guessTypeByExtension($url);
} }
$fields = self::getFields(); $fields = self::getFields();
$values = array_fill(0, count($fields), ''); $values = array_fill(0, count($fields), "");
$photo = array_combine($fields, $values); $photo = array_combine($fields, $values);
$photo['backend-class'] = ExternalResource::NAME; $photo['backend-class'] = ExternalResource::NAME;
@ -314,14 +314,14 @@ class Photo
/** /**
* store photo metadata in db and binary in default backend * store photo metadata in db and binary in default backend
* *
* @param Image $image Image object with data * @param Image $Image Image object with data
* @param integer $uid User ID * @param integer $uid User ID
* @param integer $cid Contact ID * @param integer $cid Contact ID
* @param string $rid Resource ID * @param integer $rid Resource ID
* @param string $filename Filename * @param string $filename Filename
* @param string $album Album name * @param string $album Album name
* @param integer $scale Scale * @param integer $scale Scale
* @param integer $type Photo type, optional, default: Photo::DEFAULT * @param integer $profile Is a profile image? optional, default = 0
* @param string $allow_cid Permissions, allowed contacts. optional, default = "" * @param string $allow_cid Permissions, allowed contacts. optional, default = ""
* @param string $allow_gid Permissions, allowed groups. optional, default = "" * @param string $allow_gid Permissions, allowed groups. optional, default = ""
* @param string $deny_cid Permissions, denied contacts.optional, default = "" * @param string $deny_cid Permissions, denied contacts.optional, default = ""
@ -331,71 +331,71 @@ class Photo
* @return boolean True on success * @return boolean True on success
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function store(Image $image, int $uid, int $cid, string $rid, string $filename, string $album, int $scale, int $type = self::DEFAULT, string $allow_cid = '', string $allow_gid = '', string $deny_cid = '', string $deny_gid = '', string $desc = ''): bool public static function store(Image $Image, $uid, $cid, $rid, $filename, $album, $scale, $type = self::DEFAULT, $allow_cid = "", $allow_gid = "", $deny_cid = "", $deny_gid = "", $desc = "")
{ {
$photo = self::selectFirst(['guid'], ["`resource-id` = ? AND `guid` != ?", $rid, '']); $photo = self::selectFirst(["guid"], ["`resource-id` = ? AND `guid` != ?", $rid, ""]);
if (DBA::isResult($photo)) { if (DBA::isResult($photo)) {
$guid = $photo['guid']; $guid = $photo["guid"];
} else { } else {
$guid = System::createGUID(); $guid = System::createGUID();
} }
$existing_photo = self::selectFirst(['id', 'created', 'backend-class', 'backend-ref'], ['resource-id' => $rid, 'uid' => $uid, 'contact-id' => $cid, 'scale' => $scale]); $existing_photo = self::selectFirst(["id", "created", "backend-class", "backend-ref"], ["resource-id" => $rid, "uid" => $uid, "contact-id" => $cid, "scale" => $scale]);
$created = DateTimeFormat::utcNow(); $created = DateTimeFormat::utcNow();
if (DBA::isResult($existing_photo)) { if (DBA::isResult($existing_photo)) {
$created = $existing_photo['created']; $created = $existing_photo["created"];
} }
// Get defined storage backend. // Get defined storage backend.
// if no storage backend, we use old "data" column in photo table. // if no storage backend, we use old "data" column in photo table.
// if is an existing photo, reuse same backend // if is an existing photo, reuse same backend
$data = ''; $data = "";
$backend_ref = ''; $backend_ref = "";
$storage = ''; $storage = "";
try { try {
if (DBA::isResult($existing_photo)) { if (DBA::isResult($existing_photo)) {
$backend_ref = (string)$existing_photo['backend-ref']; $backend_ref = (string)$existing_photo["backend-ref"];
$storage = DI::storageManager()->getWritableStorageByName($existing_photo['backend-class'] ?? ''); $storage = DI::storageManager()->getWritableStorageByName($existing_photo["backend-class"] ?? '');
} else { } else {
$storage = DI::storage(); $storage = DI::storage();
} }
$backend_ref = $storage->put($image->asString(), $backend_ref); $backend_ref = $storage->put($Image->asString(), $backend_ref);
} catch (InvalidClassStorageException $storageException) { } catch (InvalidClassStorageException $storageException) {
$data = $image->asString(); $data = $Image->asString();
} }
$fields = [ $fields = [
'uid' => $uid, "uid" => $uid,
'contact-id' => $cid, "contact-id" => $cid,
'guid' => $guid, "guid" => $guid,
'resource-id' => $rid, "resource-id" => $rid,
'hash' => md5($image->asString()), "hash" => md5($Image->asString()),
'created' => $created, "created" => $created,
'edited' => DateTimeFormat::utcNow(), "edited" => DateTimeFormat::utcNow(),
'filename' => basename($filename), "filename" => basename($filename),
'type' => $image->getType(), "type" => $Image->getType(),
'album' => $album, "album" => $album,
'height' => $image->getHeight(), "height" => $Image->getHeight(),
'width' => $image->getWidth(), "width" => $Image->getWidth(),
'datasize' => strlen($image->asString()), "datasize" => strlen($Image->asString()),
'data' => $data, "data" => $data,
'scale' => $scale, "scale" => $scale,
'photo-type' => $type, "photo-type" => $type,
'profile' => false, "profile" => false,
'allow_cid' => $allow_cid, "allow_cid" => $allow_cid,
'allow_gid' => $allow_gid, "allow_gid" => $allow_gid,
'deny_cid' => $deny_cid, "deny_cid" => $deny_cid,
'deny_gid' => $deny_gid, "deny_gid" => $deny_gid,
'desc' => $desc, "desc" => $desc,
'backend-class' => (string)$storage, "backend-class" => (string)$storage,
'backend-ref' => $backend_ref "backend-ref" => $backend_ref
]; ];
if (DBA::isResult($existing_photo)) { if (DBA::isResult($existing_photo)) {
$r = DBA::update('photo', $fields, ['id' => $existing_photo['id']]); $r = DBA::update("photo", $fields, ["id" => $existing_photo["id"]]);
} else { } else {
$r = DBA::insert('photo', $fields); $r = DBA::insert("photo", $fields);
} }
return $r; return $r;
@ -413,7 +413,7 @@ class Photo
* @throws \Exception * @throws \Exception
* @see \Friendica\Database\DBA::delete * @see \Friendica\Database\DBA::delete
*/ */
public static function delete(array $conditions, array $options = []): bool public static function delete(array $conditions, array $options = [])
{ {
// get photo to delete data info // get photo to delete data info
$photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions); $photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions);
@ -423,7 +423,7 @@ class Photo
$backend_class = DI::storageManager()->getWritableStorageByName($photo['backend-class'] ?? ''); $backend_class = DI::storageManager()->getWritableStorageByName($photo['backend-class'] ?? '');
$backend_class->delete($photo['backend-ref'] ?? ''); $backend_class->delete($photo['backend-ref'] ?? '');
// Delete the photos after they had been deleted successfully // Delete the photos after they had been deleted successfully
DBA::delete('photo', ['id' => $photo['id']]); DBA::delete("photo", ['id' => $photo['id']]);
} catch (InvalidClassStorageException $storageException) { } catch (InvalidClassStorageException $storageException) {
DI::logger()->debug('Storage class not found.', ['conditions' => $conditions, 'exception' => $storageException]); DI::logger()->debug('Storage class not found.', ['conditions' => $conditions, 'exception' => $storageException]);
} catch (ReferenceStorageException $referenceStorageException) { } catch (ReferenceStorageException $referenceStorageException) {
@ -433,34 +433,34 @@ class Photo
DBA::close($photos); DBA::close($photos);
return DBA::delete('photo', $conditions, $options); return DBA::delete("photo", $conditions, $options);
} }
/** /**
* Update a photo * Update a photo
* *
* @param array $fields Contains the fields that are updated * @param array $fields Contains the fields that are updated
* @param array $conditions Condition array with the key values * @param array $conditions Condition array with the key values
* @param Image $image Image to update. Optional, default null. * @param Image $img Image to update. Optional, default null.
* @param array $old_fields Array with the old field values that are about to be replaced (true = update on duplicate) * @param array|boolean $old_fields Array with the old field values that are about to be replaced (true = update on duplicate)
* *
* @return boolean Was the update successfull? * @return boolean Was the update successfull?
* *
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @see \Friendica\Database\DBA::update * @see \Friendica\Database\DBA::update
*/ */
public static function update(array $fields, array $conditions, Image $image = null, array $old_fields = []): bool public static function update($fields, $conditions, Image $img = null, array $old_fields = [])
{ {
if (!is_null($image)) { if (!is_null($img)) {
// get photo to update // get photo to update
$photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions); $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
foreach($photos as $photo) { foreach($photos as $photo) {
try { try {
$backend_class = DI::storageManager()->getWritableStorageByName($photo['backend-class'] ?? ''); $backend_class = DI::storageManager()->getWritableStorageByName($photo['backend-class'] ?? '');
$fields['backend-ref'] = $backend_class->put($image->asString(), $photo['backend-ref']); $fields["backend-ref"] = $backend_class->put($img->asString(), $photo['backend-ref']);
} catch (InvalidClassStorageException $storageException) { } catch (InvalidClassStorageException $storageException) {
$fields['data'] = $image->asString(); $fields["data"] = $img->asString();
} }
} }
$fields['updated'] = DateTimeFormat::utcNow(); $fields['updated'] = DateTimeFormat::utcNow();
@ -468,7 +468,7 @@ class Photo
$fields['edited'] = DateTimeFormat::utcNow(); $fields['edited'] = DateTimeFormat::utcNow();
return DBA::update('photo', $fields, $conditions, $old_fields); return DBA::update("photo", $fields, $conditions, $old_fields);
} }
/** /**
@ -476,20 +476,20 @@ class Photo
* @param integer $uid user id * @param integer $uid user id
* @param integer $cid contact id * @param integer $cid contact id
* @param boolean $quit_on_error optional, default false * @param boolean $quit_on_error optional, default false
* @return array|bool Array on success, false on error * @return array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function importProfilePhoto(string $image_url, int $uid, int $cid, bool $quit_on_error = false) public static function importProfilePhoto($image_url, $uid, $cid, $quit_on_error = false)
{ {
$thumb = ''; $thumb = "";
$micro = ''; $micro = "";
$photo = DBA::selectFirst( $photo = DBA::selectFirst(
'photo', ['resource-id'], ['uid' => $uid, 'contact-id' => $cid, 'scale' => 4, 'photo-type' => self::CONTACT_AVATAR] "photo", ["resource-id"], ["uid" => $uid, "contact-id" => $cid, "scale" => 4, "photo-type" => self::CONTACT_AVATAR]
); );
if (!empty($photo['resource-id'])) { if (!empty($photo['resource-id'])) {
$resource_id = $photo['resource-id']; $resource_id = $photo["resource-id"];
} else { } else {
$resource_id = self::newResource(); $resource_id = self::newResource();
} }
@ -507,66 +507,66 @@ class Photo
$type = ''; $type = '';
} }
if ($quit_on_error && ($img_str == '')) { if ($quit_on_error && ($img_str == "")) {
return false; return false;
} }
$type = Images::getMimeTypeByData($img_str, $image_url, $type); $type = Images::getMimeTypeByData($img_str, $image_url, $type);
$image = new Image($img_str, $type); $Image = new Image($img_str, $type);
if ($image->isValid()) { if ($Image->isValid()) {
$image->scaleToSquare(300); $Image->scaleToSquare(300);
$filesize = strlen($image->asString()); $filesize = strlen($Image->asString());
$maximagesize = DI::config()->get('system', 'maximagesize'); $maximagesize = DI::config()->get('system', 'maximagesize');
if (!empty($maximagesize) && ($filesize > $maximagesize)) { if (!empty($maximagesize) && ($filesize > $maximagesize)) {
Logger::info('Avatar exceeds image limit', ['uid' => $uid, 'cid' => $cid, 'maximagesize' => $maximagesize, 'size' => $filesize, 'type' => $image->getType()]); Logger::info('Avatar exceeds image limit', ['uid' => $uid, 'cid' => $cid, 'maximagesize' => $maximagesize, 'size' => $filesize, 'type' => $Image->getType()]);
if ($image->getType() == 'image/gif') { if ($Image->getType() == 'image/gif') {
$image->toStatic(); $Image->toStatic();
$image = new Image($image->asString(), 'image/png'); $Image = new Image($Image->asString(), 'image/png');
$filesize = strlen($image->asString()); $filesize = strlen($Image->asString());
Logger::info('Converted gif to a static png', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'type' => $image->getType()]); Logger::info('Converted gif to a static png', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'type' => $Image->getType()]);
} }
if ($filesize > $maximagesize) { if ($filesize > $maximagesize) {
foreach ([160, 80] as $pixels) { foreach ([160, 80] as $pixels) {
if ($filesize > $maximagesize) { if ($filesize > $maximagesize) {
Logger::info('Resize', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'max' => $maximagesize, 'pixels' => $pixels, 'type' => $image->getType()]); Logger::info('Resize', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'max' => $maximagesize, 'pixels' => $pixels, 'type' => $Image->getType()]);
$image->scaleDown($pixels); $Image->scaleDown($pixels);
$filesize = strlen($image->asString()); $filesize = strlen($Image->asString());
} }
} }
} }
Logger::info('Avatar is resized', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'type' => $image->getType()]); Logger::info('Avatar is resized', ['uid' => $uid, 'cid' => $cid, 'size' => $filesize, 'type' => $Image->getType()]);
} }
$r = self::store($image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 4, self::CONTACT_AVATAR); $r = self::store($Image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 4, self::CONTACT_AVATAR);
if ($r === false) { if ($r === false) {
$photo_failure = true; $photo_failure = true;
} }
$image->scaleDown(80); $Image->scaleDown(80);
$r = self::store($image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 5, self::CONTACT_AVATAR); $r = self::store($Image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 5, self::CONTACT_AVATAR);
if ($r === false) { if ($r === false) {
$photo_failure = true; $photo_failure = true;
} }
$image->scaleDown(48); $Image->scaleDown(48);
$r = self::store($image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 6, self::CONTACT_AVATAR); $r = self::store($Image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 6, self::CONTACT_AVATAR);
if ($r === false) { if ($r === false) {
$photo_failure = true; $photo_failure = true;
} }
$suffix = '?ts=' . time(); $suffix = "?ts=" . time();
$image_url = DI::baseUrl() . '/photo/' . $resource_id . '-4.' . $image->getExt() . $suffix; $image_url = DI::baseUrl() . "/photo/" . $resource_id . "-4." . $Image->getExt() . $suffix;
$thumb = DI::baseUrl() . '/photo/' . $resource_id . '-5.' . $image->getExt() . $suffix; $thumb = DI::baseUrl() . "/photo/" . $resource_id . "-5." . $Image->getExt() . $suffix;
$micro = DI::baseUrl() . '/photo/' . $resource_id . '-6.' . $image->getExt() . $suffix; $micro = DI::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix;
} else { } else {
$photo_failure = true; $photo_failure = true;
} }
@ -590,33 +590,31 @@ class Photo
* @param string $hemi hemi * @param string $hemi hemi
* @return float * @return float
*/ */
public static function getGps(array $exifCoord, string $hemi): float public static function getGps($exifCoord, $hemi)
{ {
$degrees = count($exifCoord) > 0 ? self::gps2Num($exifCoord[0]) : 0; $degrees = count($exifCoord) > 0 ? self::gps2Num($exifCoord[0]) : 0;
$minutes = count($exifCoord) > 1 ? self::gps2Num($exifCoord[1]) : 0; $minutes = count($exifCoord) > 1 ? self::gps2Num($exifCoord[1]) : 0;
$seconds = count($exifCoord) > 2 ? self::gps2Num($exifCoord[2]) : 0; $seconds = count($exifCoord) > 2 ? self::gps2Num($exifCoord[2]) : 0;
$flip = ($hemi == 'W' || $hemi == 'S') ? -1 : 1; $flip = ($hemi == "W" || $hemi == "S") ? -1 : 1;
return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600))); return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600)));
} }
/** /**
* Change GPS to float number
*
* @param string $coordPart coordPart * @param string $coordPart coordPart
* @return float * @return float
*/ */
private static function gps2Num(string $coordPart): float private static function gps2Num($coordPart)
{ {
$parts = explode('/', $coordPart); $parts = explode("/", $coordPart);
if (count($parts) <= 0) { if (count($parts) <= 0) {
return 0; return 0;
} }
if (count($parts) == 1) { if (count($parts) == 1) {
return (float)$parts[0]; return $parts[0];
} }
return floatval($parts[0]) / floatval($parts[1]); return floatval($parts[0]) / floatval($parts[1]);
@ -633,18 +631,17 @@ class Photo
* @return array Returns array of the photo albums * @return array Returns array of the photo albums
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function getAlbums(int $uid, bool $update = false): array public static function getAlbums($uid, $update = false)
{ {
$sql_extra = Security::getPermissionsSQLByUserId($uid); $sql_extra = Security::getPermissionsSQLByUserId($uid);
$avatar_type = (local_user() && (local_user() == $uid)) ? self::USER_AVATAR : self::DEFAULT; $avatar_type = (local_user() && (local_user() == $uid)) ? self::USER_AVATAR : self::DEFAULT;
$banner_type = (local_user() && (local_user() == $uid)) ? self::USER_BANNER : self::DEFAULT; $banner_type = (local_user() && (local_user() == $uid)) ? self::USER_BANNER : self::DEFAULT;
$key = 'photo_albums:' . $uid . ':' . local_user() . ':' . remote_user(); $key = "photo_albums:".$uid.":".local_user().":".remote_user();
$albums = DI::cache()->get($key); $albums = DI::cache()->get($key);
if (is_null($albums) || $update) { if (is_null($albums) || $update) {
if (!DI::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 /// @todo This query needs to be renewed. It is really slow
// At this time we just store the data in the cache // At this time we just store the data in the cache
$albums = DBA::toArray(DBA::p("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`, ANY_VALUE(`created`) AS `created` $albums = DBA::toArray(DBA::p("SELECT COUNT(DISTINCT `resource-id`) AS `total`, `album`, ANY_VALUE(`created`) AS `created`
@ -677,19 +674,19 @@ class Photo
* @return void * @return void
* @throws \Exception * @throws \Exception
*/ */
public static function clearAlbumCache(int $uid) public static function clearAlbumCache($uid)
{ {
$key = 'photo_albums:' . $uid . ':' . local_user() . ':' . remote_user(); $key = "photo_albums:".$uid.":".local_user().":".remote_user();
DI::cache()->set($key, null, Duration::DAY); DI::cache()->set($key, null, Duration::DAY);
} }
/** /**
* Generate a unique photo ID. * Generate a unique photo ID.
* *
* @return string Resource GUID * @return string
* @throws \Exception * @throws \Exception
*/ */
public static function newResource(): string public static function newResource()
{ {
return System::createGUID(32, false); return System::createGUID(32, false);
} }
@ -700,7 +697,7 @@ class Photo
* @param string $image_uri The URI of the photo * @param string $image_uri The URI of the photo
* @return string The rid of the photo, or an empty string if the URI is not local * @return string The rid of the photo, or an empty string if the URI is not local
*/ */
public static function ridFromURI(string $image_uri): string public static function ridFromURI(string $image_uri)
{ {
if (!stristr($image_uri, DI::baseUrl() . '/photo/')) { if (!stristr($image_uri, DI::baseUrl() . '/photo/')) {
return ''; return '';
@ -812,7 +809,7 @@ class Photo
* @param string $name Picture link * @param string $name Picture link
* @return array * @return array
*/ */
public static function getResourceData(string $name): array public static function getResourceData(string $name):array
{ {
$base = DI::baseUrl()->get(); $base = DI::baseUrl()->get();
@ -843,9 +840,8 @@ class Photo
* @return boolean * @return boolean
* @throws \Exception * @throws \Exception
*/ */
public static function isLocal(string $name): bool public static function isLocal($name)
{ {
// @TODO Maybe a proper check here on true condition?
return (bool)self::getIdForName($name); return (bool)self::getIdForName($name);
} }
@ -855,7 +851,7 @@ class Photo
* @param string $name Picture link * @param string $name Picture link
* @return int * @return int
*/ */
public static function getIdForName(string $name): int public static function getIdForName($name)
{ {
$data = self::getResourceData($name); $data = self::getResourceData($name);
if (empty($data)) { if (empty($data)) {
@ -876,7 +872,7 @@ class Photo
* @return boolean * @return boolean
* @throws \Exception * @throws \Exception
*/ */
public static function isLocalPage(string $name): bool public static function isLocalPage($name)
{ {
$base = DI::baseUrl()->get(); $base = DI::baseUrl()->get();
@ -889,23 +885,17 @@ class Photo
return DBA::exists('photo', ['resource-id' => $guid]); return DBA::exists('photo', ['resource-id' => $guid]);
} }
/** private static function fitImageSize($Image)
* Tries to resize image to wanted maximum size
*
* @param Image $image Image instance
* @return Image|null Image instance on success, null on error
*/
private static function fitImageSize(Image $image)
{ {
$max_length = DI::config()->get('system', 'max_image_length'); $max_length = DI::config()->get('system', 'max_image_length');
if ($max_length > 0) { if ($max_length > 0) {
$image->scaleDown($max_length); $Image->scaleDown($max_length);
Logger::info('File upload: Scaling picture to new size', ['max-length' => $max_length]); Logger::info('File upload: Scaling picture to new size', ['max-length' => $max_length]);
} }
$filesize = strlen($image->asString()); $filesize = strlen($Image->asString());
$width = $image->getWidth(); $width = $Image->getWidth();
$height = $image->getHeight(); $height = $Image->getHeight();
$maximagesize = DI::config()->get('system', 'maximagesize'); $maximagesize = DI::config()->get('system', 'maximagesize');
@ -914,10 +904,10 @@ class Photo
foreach ([5120, 2560, 1280, 640] as $pixels) { foreach ([5120, 2560, 1280, 640] as $pixels) {
if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) { if (($filesize > $maximagesize) && (max($width, $height) > $pixels)) {
Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]); Logger::info('Resize', ['size' => $filesize, 'width' => $width, 'height' => $height, 'max' => $maximagesize, 'pixels' => $pixels]);
$image->scaleDown($pixels); $Image->scaleDown($pixels);
$filesize = strlen($image->asString()); $filesize = strlen($Image->asString());
$width = $image->getWidth(); $width = $Image->getWidth();
$height = $image->getHeight(); $height = $Image->getHeight();
} }
} }
if ($filesize > $maximagesize) { if ($filesize > $maximagesize) {
@ -926,16 +916,10 @@ class Photo
} }
} }
return $image; return $Image;
} }
/** private static function loadImageFromURL(string $image_url)
* Fetches image from URL and returns an array with instance and local file name
*
* @param string $image_url URL to image
* @return array With: 'image' and 'filename' fields or empty array on error
*/
private static function loadImageFromURL(string $image_url): array
{ {
$filename = basename($image_url); $filename = basename($image_url);
if (!empty($image_url)) { if (!empty($image_url)) {
@ -955,23 +939,17 @@ class Photo
$type = Images::getMimeTypeByData($img_str, $image_url, $type); $type = Images::getMimeTypeByData($img_str, $image_url, $type);
$image = new Image($img_str, $type); $Image = new Image($img_str, $type);
$image = self::fitImageSize($image); $Image = self::fitImageSize($Image);
if (empty($image)) { if (empty($Image)) {
return []; return [];
} }
return ['image' => $image, 'filename' => $filename]; return ['image' => $Image, 'filename' => $filename];
} }
/** private static function uploadImage(array $files)
* Inserts uploaded image into database and removes local temporary file
*
* @param array $files File array
* @return array With 'image' for Image instance and 'filename' for local file name or empty array on error
*/
private static function uploadImage(array $files): array
{ {
Logger::info('starting new upload'); Logger::info('starting new upload');
@ -1030,36 +1008,34 @@ class Photo
Logger::info('File upload', ['src' => $src, 'filename' => $filename, 'size' => $filesize, 'type' => $filetype]); Logger::info('File upload', ['src' => $src, 'filename' => $filename, 'size' => $filesize, 'type' => $filetype]);
$imagedata = @file_get_contents($src); $imagedata = @file_get_contents($src);
$image = new Image($imagedata, $filetype); $Image = new Image($imagedata, $filetype);
if (!$image->isValid()) { if (!$Image->isValid()) {
Logger::notice('Image is unvalid', ['files' => $files]); Logger::notice('Image is unvalid', ['files' => $files]);
return []; return [];
} }
$image->orient($src); $Image->orient($src);
@unlink($src); @unlink($src);
$image = self::fitImageSize($image); $Image = self::fitImageSize($Image);
if (empty($image)) { if (empty($Image)) {
return []; return [];
} }
return ['image' => $image, 'filename' => $filename]; return ['image' => $Image, 'filename' => $filename];
} }
/** /**
* Handles uploaded image and assigns it to given user id
*
* @param int $uid User ID * @param int $uid User ID
* @param array $files uploaded file array * @param array $files uploaded file array
* @param string $album Album name (optional) * @param string $album
* @param string|null $allow_cid * @param string|null $allow_cid
* @param string|null $allow_gid * @param string|null $allow_gid
* @param string $deny_cid * @param string $deny_cid
* @param string $deny_gid * @param string $deny_gid
* @param string $desc Description (optional) * @param string $desc
* @param string $resource_id GUID (optional) * @param string $resource_id
* @return array photo record or empty array on error * @return array photo record
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function upload(int $uid, array $files, string $album = '', string $allow_cid = null, string $allow_gid = null, string $deny_cid = '', string $deny_gid = '', string $desc = '', string $resource_id = ''): array public static function upload(int $uid, array $files, string $album = '', string $allow_cid = null, string $allow_gid = null, string $deny_cid = '', string $deny_gid = '', string $desc = '', string $resource_id = ''): array
@ -1076,10 +1052,10 @@ class Photo
return []; return [];
} }
$image = $data['image']; $Image = $data['image'];
$filename = $data['filename']; $filename = $data['filename'];
$width = $image->getWidth(); $width = $Image->getWidth();
$height = $image->getHeight(); $height = $Image->getHeight();
$resource_id = $resource_id ?: self::newResource(); $resource_id = $resource_id ?: self::newResource();
$album = $album ?: DI::l10n()->t('Wall Photos'); $album = $album ?: DI::l10n()->t('Wall Photos');
@ -1091,23 +1067,23 @@ class Photo
$smallest = 0; $smallest = 0;
$r = self::store($image, $user['uid'], 0, $resource_id, $filename, $album, 0, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); $r = self::store($Image, $user['uid'], 0, $resource_id, $filename, $album, 0, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if (!$r) { if (!$r) {
Logger::notice('Photo could not be stored'); Logger::notice('Photo could not be stored');
return []; return [];
} }
if ($width > 640 || $height > 640) { if ($width > 640 || $height > 640) {
$image->scaleDown(640); $Image->scaleDown(640);
$r = self::store($image, $user['uid'], 0, $resource_id, $filename, $album, 1, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); $r = self::store($Image, $user['uid'], 0, $resource_id, $filename, $album, 1, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if ($r) { if ($r) {
$smallest = 1; $smallest = 1;
} }
} }
if ($width > 320 || $height > 320) { if ($width > 320 || $height > 320) {
$image->scaleDown(320); $Image->scaleDown(320);
$r = self::store($image, $user['uid'], 0, $resource_id, $filename, $album, 2, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc); $r = self::store($Image, $user['uid'], 0, $resource_id, $filename, $album, 2, self::DEFAULT, $allow_cid, $allow_gid, $deny_cid, $deny_gid, $desc);
if ($r && ($smallest == 0)) { if ($r && ($smallest == 0)) {
$smallest = 2; $smallest = 2;
} }
@ -1129,8 +1105,8 @@ class Photo
$picture['height'] = $photo['height']; $picture['height'] = $photo['height'];
$picture['type'] = $photo['type']; $picture['type'] = $photo['type'];
$picture['albumpage'] = DI::baseUrl() . '/photos/' . $user['nickname'] . '/image/' . $resource_id; $picture['albumpage'] = DI::baseUrl() . '/photos/' . $user['nickname'] . '/image/' . $resource_id;
$picture['picture'] = DI::baseUrl() . '/photo/{$resource_id}-0.' . $image->getExt(); $picture['picture'] = DI::baseUrl() . '/photo/{$resource_id}-0.' . $Image->getExt();
$picture['preview'] = DI::baseUrl() . '/photo/{$resource_id}-{$smallest}.' . $image->getExt(); $picture['preview'] = DI::baseUrl() . '/photo/{$resource_id}-{$smallest}.' . $Image->getExt();
Logger::info('upload done', ['picture' => $picture]); Logger::info('upload done', ['picture' => $picture]);
return $picture; return $picture;
@ -1163,10 +1139,10 @@ class Photo
return ''; return '';
} }
$image = $data['image']; $Image = $data['image'];
$filename = $data['filename']; $filename = $data['filename'];
$width = $image->getWidth(); $width = $Image->getWidth();
$height = $image->getHeight(); $height = $Image->getHeight();
$resource_id = self::newResource(); $resource_id = self::newResource();
$album = DI::l10n()->t(self::PROFILE_PHOTOS); $album = DI::l10n()->t(self::PROFILE_PHOTOS);
@ -1175,28 +1151,28 @@ class Photo
logger::info('starting new profile image upload'); logger::info('starting new profile image upload');
if ($width > 300 || $height > 300) { if ($width > 300 || $height > 300) {
$image->scaleDown(300); $Image->scaleDown(300);
} }
$r = self::store($image, $uid, 0, $resource_id, $filename, $album, 4, self::USER_AVATAR); $r = self::store($Image, $uid, 0, $resource_id, $filename, $album, 4, self::USER_AVATAR);
if (!$r) { if (!$r) {
logger::notice('profile image upload with scale 4 (300) failed'); logger::notice('profile image upload with scale 4 (300) failed');
} }
if ($width > 80 || $height > 80) { if ($width > 80 || $height > 80) {
$image->scaleDown(80); $Image->scaleDown(80);
} }
$r = self::store($image, $uid, 0, $resource_id, $filename, $album, 5, self::USER_AVATAR); $r = self::store($Image, $uid, 0, $resource_id, $filename, $album, 5, self::USER_AVATAR);
if (!$r) { if (!$r) {
logger::notice('profile image upload with scale 5 (80) failed'); logger::notice('profile image upload with scale 5 (80) failed');
} }
if ($width > 48 || $height > 48) { if ($width > 48 || $height > 48) {
$image->scaleDown(48); $Image->scaleDown(48);
} }
$r = self::store($image, $uid, 0, $resource_id, $filename, $album, 6, self::USER_AVATAR); $r = self::store($Image, $uid, 0, $resource_id, $filename, $album, 6, self::USER_AVATAR);
if (!$r) { if (!$r) {
logger::notice('profile image upload with scale 6 (48) failed'); logger::notice('profile image upload with scale 6 (48) failed');
} }
@ -1241,19 +1217,19 @@ class Photo
return ''; return '';
} }
$image = $data['image']; $Image = $data['image'];
$filename = $data['filename']; $filename = $data['filename'];
$width = $image->getWidth(); $width = $Image->getWidth();
$height = $image->getHeight(); $height = $Image->getHeight();
$resource_id = self::newResource(); $resource_id = self::newResource();
$album = DI::l10n()->t(self::BANNER_PHOTOS); $album = DI::l10n()->t(self::BANNER_PHOTOS);
if ($width > 960) { if ($width > 960) {
$image->scaleDown(960); $Image->scaleDown(960);
} }
$r = self::store($image, $uid, 0, $resource_id, $filename, $album, 3, self::USER_BANNER); $r = self::store($Image, $uid, 0, $resource_id, $filename, $album, 3, self::USER_BANNER);
if (!$r) { if (!$r) {
logger::notice('profile banner upload with scale 3 (960) failed'); logger::notice('profile banner upload with scale 3 (960) failed');
} }
@ -1271,4 +1247,3 @@ class Photo
return $resource_id; return $resource_id;
} }
} }

View file

@ -39,7 +39,7 @@ class Post
* @return int ID of inserted post * @return int ID of inserted post
* @throws \Exception * @throws \Exception
*/ */
public static function insert(int $uri_id, array $data = []): int public static function insert(int $uri_id, array $data = [])
{ {
if (empty($uri_id)) { if (empty($uri_id)) {
throw new BadMethodCallException('Empty URI_id'); throw new BadMethodCallException('Empty URI_id');
@ -107,10 +107,8 @@ class Post
* @param object $stmt statement object * @param object $stmt statement object
* @param bool $do_close * @param bool $do_close
* @return array Data array * @return array Data array
* @todo Find proper type-hint for $stmt and maybe avoid boolean
*/ */
public static function toArray($stmt, bool $do_close = true) public static function toArray($stmt, $do_close = true) {
{
if (is_bool($stmt)) { if (is_bool($stmt)) {
return $stmt; return $stmt;
} }
@ -133,8 +131,7 @@ class Post
* @return boolean Are there rows for that condition? * @return boolean Are there rows for that condition?
* @throws \Exception * @throws \Exception
*/ */
public static function exists(array $condition): bool public static function exists($condition) {
{
return DBA::exists('post-user-view', $condition); return DBA::exists('post-user-view', $condition);
} }
@ -154,7 +151,7 @@ class Post
* $count = Post::count($condition); * $count = Post::count($condition);
* @throws \Exception * @throws \Exception
*/ */
public static function count(array $condition = [], array $params = []): int public static function count(array $condition = [], array $params = [])
{ {
return DBA::count('post-user-view', $condition, $params); return DBA::count('post-user-view', $condition, $params);
} }
@ -175,7 +172,7 @@ class Post
* $count = Post::count($condition); * $count = Post::count($condition);
* @throws \Exception * @throws \Exception
*/ */
public static function countThread(array $condition = [], array $params = []): int public static function countThread(array $condition = [], array $params = [])
{ {
return DBA::count('post-thread-user-view', $condition, $params); return DBA::count('post-thread-user-view', $condition, $params);
} }
@ -196,7 +193,7 @@ class Post
* $count = Post::count($condition); * $count = Post::count($condition);
* @throws \Exception * @throws \Exception
*/ */
public static function countPosts(array $condition = [], array $params = []): int public static function countPosts(array $condition = [], array $params = [])
{ {
return DBA::count('post-view', $condition, $params); return DBA::count('post-view', $condition, $params);
} }
@ -212,7 +209,7 @@ class Post
* @throws \Exception * @throws \Exception
* @see DBA::select * @see DBA::select
*/ */
public static function selectFirst(array $fields = [], array $condition = [], array $params = []) public static function selectFirst(array $fields = [], array $condition = [], $params = [])
{ {
$params['limit'] = 1; $params['limit'] = 1;
@ -237,7 +234,7 @@ class Post
* @throws \Exception * @throws \Exception
* @see DBA::select * @see DBA::select
*/ */
public static function selectFirstPost(array $fields = [], array $condition = [], array $params = []) public static function selectFirstPost(array $fields = [], array $condition = [], $params = [])
{ {
$params['limit'] = 1; $params['limit'] = 1;
@ -262,7 +259,7 @@ class Post
* @throws \Exception * @throws \Exception
* @see DBA::select * @see DBA::select
*/ */
public static function selectFirstThread(array $fields = [], array $condition = [], array $params = []) public static function selectFirstThread(array $fields = [], array $condition = [], $params = [])
{ {
$params['limit'] = 1; $params['limit'] = 1;
@ -287,7 +284,7 @@ class Post
* @return array * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function selectToArray(array $fields = [], array $condition = [], array $params = []) public static function selectToArray(array $fields = [], array $condition = [], $params = [])
{ {
$result = self::select($fields, $condition, $params); $result = self::select($fields, $condition, $params);
@ -315,7 +312,7 @@ class Post
* @return boolean|object * @return boolean|object
* @throws \Exception * @throws \Exception
*/ */
private static function selectView(string $view, array $selected = [], array $condition = [], array $params = []) private static function selectView(string $view, array $selected = [], array $condition = [], $params = [])
{ {
if (empty($selected)) { if (empty($selected)) {
$selected = array_merge(Item::DISPLAY_FIELDLIST, Item::ITEM_FIELDLIST); $selected = array_merge(Item::DISPLAY_FIELDLIST, Item::ITEM_FIELDLIST);
@ -340,7 +337,7 @@ class Post
* @return boolean|object * @return boolean|object
* @throws \Exception * @throws \Exception
*/ */
public static function select(array $selected = [], array $condition = [], array $params = []) public static function select(array $selected = [], array $condition = [], $params = [])
{ {
return self::selectView('post-user-view', $selected, $condition, $params); return self::selectView('post-user-view', $selected, $condition, $params);
} }
@ -355,7 +352,7 @@ class Post
* @return boolean|object * @return boolean|object
* @throws \Exception * @throws \Exception
*/ */
public static function selectPosts(array $selected = [], array $condition = [], array $params = []) public static function selectPosts(array $selected = [], array $condition = [], $params = [])
{ {
return self::selectView('post-view', $selected, $condition, $params); return self::selectView('post-view', $selected, $condition, $params);
} }
@ -370,7 +367,7 @@ class Post
* @return boolean|object * @return boolean|object
* @throws \Exception * @throws \Exception
*/ */
public static function selectThread(array $selected = [], array $condition = [], array $params = []) public static function selectThread(array $selected = [], array $condition = [], $params = [])
{ {
return self::selectView('post-thread-user-view', $selected, $condition, $params); return self::selectView('post-thread-user-view', $selected, $condition, $params);
} }
@ -387,7 +384,7 @@ class Post
* @return boolean|object * @return boolean|object
* @throws \Exception * @throws \Exception
*/ */
private static function selectViewForUser(string $view, int $uid, array $selected = [], array $condition = [], array $params = []) private static function selectViewForUser(string $view, $uid, array $selected = [], array $condition = [], $params = [])
{ {
if (empty($selected)) { if (empty($selected)) {
$selected = Item::DISPLAY_FIELDLIST; $selected = Item::DISPLAY_FIELDLIST;
@ -428,7 +425,7 @@ class Post
* @return boolean|object * @return boolean|object
* @throws \Exception * @throws \Exception
*/ */
public static function selectForUser(int $uid, array $selected = [], array $condition = [], array $params = []) public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
{ {
return self::selectViewForUser('post-user-view', $uid, $selected, $condition, $params); return self::selectViewForUser('post-user-view', $uid, $selected, $condition, $params);
} }
@ -444,7 +441,7 @@ class Post
* @return boolean|object * @return boolean|object
* @throws \Exception * @throws \Exception
*/ */
public static function selectPostsForUser(int $uid, array $selected = [], array $condition = [], array $params = []) public static function selectPostsForUser($uid, array $selected = [], array $condition = [], $params = [])
{ {
return self::selectViewForUser('post-view', $uid, $selected, $condition, $params); return self::selectViewForUser('post-view', $uid, $selected, $condition, $params);
} }
@ -460,7 +457,7 @@ class Post
* @return boolean|object * @return boolean|object
* @throws \Exception * @throws \Exception
*/ */
public static function selectThreadForUser(int $uid, array $selected = [], array $condition = [], array $params = []) public static function selectThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
{ {
return self::selectViewForUser('post-thread-user-view', $uid, $selected, $condition, $params); return self::selectViewForUser('post-thread-user-view', $uid, $selected, $condition, $params);
} }
@ -476,7 +473,7 @@ class Post
* @throws \Exception * @throws \Exception
* @see DBA::select * @see DBA::select
*/ */
public static function selectFirstForUser(int $uid, array $selected = [], array $condition = [], array $params = []) public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
{ {
$params['limit'] = 1; $params['limit'] = 1;
@ -643,7 +640,7 @@ class Post
* @return boolean was the delete successful? * @return boolean was the delete successful?
* @throws \Exception * @throws \Exception
*/ */
public static function delete(array $conditions, array $options = []): bool public static function delete(array $conditions, array $options = [])
{ {
return DBA::delete('post', $conditions, $options); return DBA::delete('post', $conditions, $options);
} }

View file

@ -109,7 +109,7 @@ class Media
* @param array $media * @param array $media
* @return array cleaned media array * @return array cleaned media array
*/ */
private static function unsetEmptyFields(array $media): array private static function unsetEmptyFields(array $media)
{ {
$fields = ['mimetype', 'height', 'width', 'size', 'preview', 'preview-height', 'preview-width', 'description']; $fields = ['mimetype', 'height', 'width', 'size', 'preview', 'preview-height', 'preview-width', 'description'];
foreach ($fields as $field) { foreach ($fields as $field) {
@ -145,7 +145,7 @@ class Media
* @param string $title * @param string $title
* @return string "[attach]" element * @return string "[attach]" element
*/ */
public static function getAttachElement(string $href, int $length, string $type, string $title = ''): string public static function getAttachElement(string $href, int $length, string $type, string $title = '')
{ {
$media = self::fetchAdditionalData(['type' => self::DOCUMENT, 'url' => $href, $media = self::fetchAdditionalData(['type' => self::DOCUMENT, 'url' => $href,
'size' => $length, 'mimetype' => $type, 'description' => $title]); 'size' => $length, 'mimetype' => $type, 'description' => $title]);
@ -160,7 +160,7 @@ class Media
* @param array $media * @param array $media
* @return array media array with additional data * @return array media array with additional data
*/ */
public static function fetchAdditionalData(array $media): array public static function fetchAdditionalData(array $media)
{ {
if (Network::isLocalLink($media['url'])) { if (Network::isLocalLink($media['url'])) {
$media = self::fetchLocalData($media); $media = self::fetchLocalData($media);
@ -235,7 +235,7 @@ class Media
* @param array $media * @param array $media
* @return array media with added data * @return array media with added data
*/ */
private static function fetchLocalData(array $media): array private static function fetchLocalData(array $media)
{ {
if (!preg_match('|.*?/photo/(.*[a-fA-F0-9])\-(.*[0-9])\..*[\w]|', $media['url'] ?? '', $matches)) { if (!preg_match('|.*?/photo/(.*[a-fA-F0-9])\-(.*[0-9])\..*[\w]|', $media['url'] ?? '', $matches)) {
return $media; return $media;
@ -266,7 +266,7 @@ class Media
* @param array $data * @param array $data
* @return array data array with the detected type * @return array data array with the detected type
*/ */
public static function addType(array $data): array public static function addType(array $data)
{ {
if (empty($data['mimetype'])) { if (empty($data['mimetype'])) {
Logger::info('No MimeType provided', ['media' => $data]); Logger::info('No MimeType provided', ['media' => $data]);
@ -318,7 +318,7 @@ class Media
* @param string $preview Preview picture * @param string $preview Preview picture
* @return boolean * @return boolean
*/ */
private static function isPictureLink(string $page, string $preview): bool private static function isPictureLink(string $page, string $preview)
{ {
return preg_match('#/photos/.*/image/#ism', $page) && preg_match('#/photo/.*-1\.#ism', $preview); return preg_match('#/photos/.*/image/#ism', $page) && preg_match('#/photo/.*-1\.#ism', $preview);
} }
@ -330,7 +330,7 @@ class Media
* @param string $body * @param string $body
* @return string Body without media links * @return string Body without media links
*/ */
public static function insertFromBody(int $uriid, string $body): string public static function insertFromBody(int $uriid, string $body)
{ {
// Simplify image codes // Simplify image codes
$unshared_body = $body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body); $unshared_body = $body = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $body);
@ -413,7 +413,6 @@ class Media
* *
* @param integer $uriid * @param integer $uriid
* @param string $body * @param string $body
* @return void
*/ */
public static function insertFromRelevantUrl(int $uriid, string $body) public static function insertFromRelevantUrl(int $uriid, string $body)
{ {
@ -449,7 +448,6 @@ class Media
* *
* @param integer $uriid * @param integer $uriid
* @param string $body * @param string $body
* @return void
*/ */
public static function insertFromAttachmentData(int $uriid, string $body) public static function insertFromAttachmentData(int $uriid, string $body)
{ {
@ -508,9 +506,9 @@ class Media
/** /**
* Retrieves the media attachments associated with the provided item ID. * Retrieves the media attachments associated with the provided item ID.
* *
* @param int $uri_id URI id * @param int $uri_id
* @param array $types Media types * @param array $types
* @return array|bool Array on success, false on error * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function getByURIId(int $uri_id, array $types = []) public static function getByURIId(int $uri_id, array $types = [])
@ -527,12 +525,12 @@ class Media
/** /**
* Checks if media attachments are associated with the provided item ID. * Checks if media attachments are associated with the provided item ID.
* *
* @param int $uri_id URI id * @param int $uri_id
* @param array $types Media types * @param array $types
* @return bool Whether media attachment exists * @return array
* @throws \Exception * @throws \Exception
*/ */
public static function existsByURIId(int $uri_id, array $types = []): bool public static function existsByURIId(int $uri_id, array $types = [])
{ {
$condition = ['uri-id' => $uri_id]; $condition = ['uri-id' => $uri_id];
@ -546,13 +544,13 @@ class Media
/** /**
* Split the attachment media in the three segments "visual", "link" and "additional" * Split the attachment media in the three segments "visual", "link" and "additional"
* *
* @param int $uri_id URI id * @param int $uri_id
* @param string $guid GUID * @param string $guid
* @param array $links list of links that shouldn't be added * @param array $links list of links that shouldn't be added
* @param bool $has_media * @param bool $has_media
* @return array attachments * @return array attachments
*/ */
public static function splitAttachments(int $uri_id, string $guid = '', array $links = [], bool $has_media = true): array public static function splitAttachments(int $uri_id, string $guid = '', array $links = [], bool $has_media = true)
{ {
$attachments = ['visual' => [], 'link' => [], 'additional' => []]; $attachments = ['visual' => [], 'link' => [], 'additional' => []];
@ -650,7 +648,7 @@ class Media
* @param string $body * @param string $body
* @return string body * @return string body
*/ */
public static function addAttachmentsToBody(int $uriid, string $body = ''): string public static function addAttachmentsToBody(int $uriid, string $body = '')
{ {
if (empty($body)) { if (empty($body)) {
$item = Post::selectFirst(['body'], ['uri-id' => $uriid]); $item = Post::selectFirst(['body'], ['uri-id' => $uriid]);
@ -703,7 +701,7 @@ class Media
* @param string $size One of the Proxy::SIZE_* constants * @param string $size One of the Proxy::SIZE_* constants
* @return string preview link * @return string preview link
*/ */
public static function getPreviewUrlForId(int $id, string $size = ''): string public static function getPreviewUrlForId(int $id, string $size = ''):string
{ {
$url = DI::baseUrl() . '/photo/preview/'; $url = DI::baseUrl() . '/photo/preview/';
switch ($size) { switch ($size) {
@ -733,7 +731,7 @@ class Media
* @param string $size One of the Proxy::SIZE_* constants * @param string $size One of the Proxy::SIZE_* constants
* @return string media link * @return string media link
*/ */
public static function getUrlForId(int $id, string $size = ''): string public static function getUrlForId(int $id, string $size = ''):string
{ {
$url = DI::baseUrl() . '/photo/media/'; $url = DI::baseUrl() . '/photo/media/';
switch ($size) { switch ($size) {

View file

@ -54,10 +54,10 @@ class Profile
* *
* @param integer User ID * @param integer User ID
* *
* @return array|bool Profile data or false on error * @return array Profile data
* @throws \Exception * @throws \Exception
*/ */
public static function getByUID(int $uid) public static function getByUID($uid)
{ {
return DBA::selectFirst('profile', [], ['uid' => $uid]); return DBA::selectFirst('profile', [], ['uid' => $uid]);
} }
@ -69,7 +69,7 @@ class Profile
* @param int $id The contact owner ID * @param int $id The contact owner ID
* @param array $fields The selected fields * @param array $fields The selected fields
* *
* @return array|bool Profile data for the ID or false on error * @return array Profile data for the ID
* @throws \Exception * @throws \Exception
*/ */
public static function getById(int $uid, int $id, array $fields = []) public static function getById(int $uid, int $id, array $fields = [])
@ -81,7 +81,7 @@ class Profile
* Returns profile data for the contact owner * Returns profile data for the contact owner
* *
* @param int $uid The User ID * @param int $uid The User ID
* @param array|bool $fields The fields to retrieve or false on error * @param array $fields The fields to retrieve
* *
* @return array Array of profile data * @return array Array of profile data
* @throws \Exception * @throws \Exception
@ -94,9 +94,9 @@ class Profile
/** /**
* Update a profile entry and distribute the changes if needed * Update a profile entry and distribute the changes if needed
* *
* @param array $fields Profile fields to update * @param array $fields
* @param integer $uid User id * @param integer $uid
* @return boolean Whether update was successful * @return boolean
*/ */
public static function update(array $fields, int $uid): bool public static function update(array $fields, int $uid): bool
{ {
@ -136,10 +136,8 @@ class Profile
/** /**
* Publish a changed profile * Publish a changed profile
* * @param int $uid
* @param int $uid User id
* @param bool $force Force publishing to the directory * @param bool $force Force publishing to the directory
* @return void
*/ */
public static function publishUpdate(int $uid, bool $force = false) public static function publishUpdate(int $uid, bool $force = false)
{ {
@ -165,7 +163,7 @@ class Profile
* *
* @return string Location string * @return string Location string
*/ */
public static function formatLocation(array $profile): string public static function formatLocation(array $profile)
{ {
$location = ''; $location = '';
@ -239,7 +237,7 @@ class Profile
if (!local_user()) { if (!local_user()) {
$a->setCurrentTheme($profile['theme']); $a->setCurrentTheme($profile['theme']);
$a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme') ?? ''); $a->setCurrentMobileTheme(DI::pConfig()->get($a->getProfileOwner(), 'system', 'mobile_theme'));
} }
/* /*

View file

@ -34,10 +34,9 @@ class PushSubscriber
* *
* @param integer $uid User ID * @param integer $uid User ID
* @param int $default_priority * @param int $default_priority
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function publishFeed(int $uid, int $default_priority = PRIORITY_HIGH) public static function publishFeed($uid, $default_priority = PRIORITY_HIGH)
{ {
$condition = ['push' => 0, 'uid' => $uid]; $condition = ['push' => 0, 'uid' => $uid];
DBA::update('push_subscriber', ['push' => 1, 'next_try' => DBA::NULL_DATETIME], $condition); DBA::update('push_subscriber', ['push' => 1, 'next_try' => DBA::NULL_DATETIME], $condition);
@ -49,10 +48,9 @@ class PushSubscriber
* start workers to transmit the feed data * start workers to transmit the feed data
* *
* @param int $default_priority * @param int $default_priority
* @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function requeue(int $default_priority = PRIORITY_HIGH) public static function requeue($default_priority = PRIORITY_HIGH)
{ {
// We'll push to each subscriber that has push > 0, // We'll push to each subscriber that has push > 0,
// i.e. there has been an update (set in notifier.php). // i.e. there has been an update (set in notifier.php).
@ -82,10 +80,9 @@ class PushSubscriber
* @param string $hub_callback Callback address * @param string $hub_callback Callback address
* @param string $hub_topic Feed topic * @param string $hub_topic Feed topic
* @param string $hub_secret Subscription secret * @param string $hub_secret Subscription secret
* @return void
* @throws \Exception * @throws \Exception
*/ */
public static function renew(int $uid, string $nick, int $subscribe, string $hub_callback, string $hub_topic, string $hub_secret) public static function renew($uid, $nick, $subscribe, $hub_callback, $hub_topic, $hub_secret)
{ {
// fetch the old subscription if it exists // fetch the old subscription if it exists
$subscriber = DBA::selectFirst('push_subscriber', ['last_update', 'push'], ['callback_url' => $hub_callback]); $subscriber = DBA::selectFirst('push_subscriber', ['last_update', 'push'], ['callback_url' => $hub_callback]);
@ -122,10 +119,9 @@ class PushSubscriber
* Delay the push subscriber * Delay the push subscriber
* *
* @param integer $id Subscriber ID * @param integer $id Subscriber ID
* @return void
* @throws \Exception * @throws \Exception
*/ */
public static function delay(int $id) public static function delay($id)
{ {
$subscriber = DBA::selectFirst('push_subscriber', ['push', 'callback_url', 'renewed', 'nickname'], ['id' => $id]); $subscriber = DBA::selectFirst('push_subscriber', ['push', 'callback_url', 'renewed', 'nickname'], ['id' => $id]);
if (!DBA::isResult($subscriber)) { if (!DBA::isResult($subscriber)) {
@ -162,10 +158,9 @@ class PushSubscriber
* *
* @param integer $id Subscriber ID * @param integer $id Subscriber ID
* @param string $last_update Date of last transmitted item * @param string $last_update Date of last transmitted item
* @return void
* @throws \Exception * @throws \Exception
*/ */
public static function reset(int $id, string $last_update) public static function reset($id, $last_update)
{ {
$subscriber = DBA::selectFirst('push_subscriber', ['callback_url', 'nickname'], ['id' => $id]); $subscriber = DBA::selectFirst('push_subscriber', ['callback_url', 'nickname'], ['id' => $id]);
if (!DBA::isResult($subscriber)) { if (!DBA::isResult($subscriber)) {

View file

@ -134,7 +134,7 @@ class User
* *
* @return array system account * @return array system account
*/ */
public static function getSystemAccount(): array public static function getSystemAccount()
{ {
$system = Contact::selectFirst([], ['self' => true, 'uid' => 0]); $system = Contact::selectFirst([], ['self' => true, 'uid' => 0]);
if (!DBA::isResult($system)) { if (!DBA::isResult($system)) {
@ -244,7 +244,7 @@ class User
* *
* @return string actor account name * @return string actor account name
*/ */
public static function getActorName(): string public static function getActorName()
{ {
$system_actor_name = DI::config()->get('system', 'actor_name'); $system_actor_name = DI::config()->get('system', 'actor_name');
if (!empty($system_actor_name)) { if (!empty($system_actor_name)) {
@ -278,7 +278,7 @@ class User
* @return boolean * @return boolean
* @throws Exception * @throws Exception
*/ */
public static function exists(int $uid): bool public static function exists($uid)
{ {
return DBA::exists('user', ['uid' => $uid]); return DBA::exists('user', ['uid' => $uid]);
} }
@ -289,7 +289,7 @@ class User
* @return array|boolean User record if it exists, false otherwise * @return array|boolean User record if it exists, false otherwise
* @throws Exception * @throws Exception
*/ */
public static function getById(int $uid, array $fields = []) public static function getById($uid, array $fields = [])
{ {
return !empty($uid) ? DBA::selectFirst('user', $fields, ['uid' => $uid]) : []; return !empty($uid) ? DBA::selectFirst('user', $fields, ['uid' => $uid]) : [];
} }
@ -321,7 +321,7 @@ class User
* @return array|boolean User record if it exists, false otherwise * @return array|boolean User record if it exists, false otherwise
* @throws Exception * @throws Exception
*/ */
public static function getByNickname(string $nickname, array $fields = []) public static function getByNickname($nickname, array $fields = [])
{ {
return DBA::selectFirst('user', $fields, ['nickname' => $nickname]); return DBA::selectFirst('user', $fields, ['nickname' => $nickname]);
} }
@ -334,7 +334,7 @@ class User
* @return integer user id * @return integer user id
* @throws Exception * @throws Exception
*/ */
public static function getIdForURL(string $url): int public static function getIdForURL(string $url)
{ {
// Avoid database queries when the local node hostname isn't even part of the url. // Avoid database queries when the local node hostname isn't even part of the url.
if (!Contact::isLocal($url)) { if (!Contact::isLocal($url)) {
@ -380,7 +380,7 @@ class User
* @param array $fields * @param array $fields
* @return array user * @return array user
*/ */
public static function getFirstAdmin(array $fields = []) : array public static function getFirstAdmin(array $fields = [])
{ {
if (!empty(DI::config()->get('config', 'admin_nickname'))) { if (!empty(DI::config()->get('config', 'admin_nickname'))) {
return self::getByNickname(DI::config()->get('config', 'admin_nickname'), $fields); return self::getByNickname(DI::config()->get('config', 'admin_nickname'), $fields);
@ -469,7 +469,7 @@ class User
* @return boolean|array * @return boolean|array
* @throws Exception * @throws Exception
*/ */
public static function getOwnerDataByNick(string $nick) public static function getOwnerDataByNick($nick)
{ {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => $nick]); $user = DBA::selectFirst('user', ['uid'], ['nickname' => $nick]);
@ -488,7 +488,7 @@ class User
* @return int group id * @return int group id
* @throws Exception * @throws Exception
*/ */
public static function getDefaultGroup(int $uid): int public static function getDefaultGroup($uid)
{ {
$user = DBA::selectFirst('user', ['def_gid'], ['uid' => $uid]); $user = DBA::selectFirst('user', ['def_gid'], ['uid' => $uid]);
if (DBA::isResult($user)) { if (DBA::isResult($user)) {
@ -512,7 +512,7 @@ class User
* @throws HTTPException\ForbiddenException * @throws HTTPException\ForbiddenException
* @throws HTTPException\NotFoundException * @throws HTTPException\NotFoundException
*/ */
public static function getIdFromPasswordAuthentication($user_info, string $password, bool $third_party = false) public static function getIdFromPasswordAuthentication($user_info, $password, $third_party = false)
{ {
// Addons registered with the "authenticate" hook may create the user on the // Addons registered with the "authenticate" hook may create the user on the
// fly. `getAuthenticationInfo` will fail if the user doesn't exist yet. If // fly. `getAuthenticationInfo` will fail if the user doesn't exist yet. If
@ -580,7 +580,7 @@ class User
* @return int User Id if authentication is successful * @return int User Id if authentication is successful
* @throws HTTPException\ForbiddenException * @throws HTTPException\ForbiddenException
*/ */
public static function getIdFromAuthenticateHooks(string $username, string $password): int public static function getIdFromAuthenticateHooks($username, $password)
{ {
$addon_auth = [ $addon_auth = [
'username' => $username, 'username' => $username,
@ -613,7 +613,7 @@ class User
* - User array with at least the uid and the hashed password * - User array with at least the uid and the hashed password
* *
* @param mixed $user_info * @param mixed $user_info
* @return array|null Null if not found/determined * @return array
* @throws HTTPException\NotFoundException * @throws HTTPException\NotFoundException
*/ */
public static function getAuthenticationInfo($user_info) public static function getAuthenticationInfo($user_info)
@ -671,7 +671,7 @@ class User
* @return string * @return string
* @throws Exception * @throws Exception
*/ */
public static function generateNewPassword(): string public static function generateNewPassword()
{ {
return ucfirst(Strings::getRandomName(8)) . random_int(1000, 9999); return ucfirst(Strings::getRandomName(8)) . random_int(1000, 9999);
} }
@ -683,7 +683,7 @@ class User
* @return bool * @return bool
* @throws Exception * @throws Exception
*/ */
public static function isPasswordExposed(string $password): bool public static function isPasswordExposed($password)
{ {
$cache = new CacheItemPool(); $cache = new CacheItemPool();
$cache->changeConfig([ $cache->changeConfig([
@ -712,7 +712,7 @@ class User
* @param string $password * @param string $password
* @return string * @return string
*/ */
private static function hashPasswordLegacy(string $password): string private static function hashPasswordLegacy($password)
{ {
return hash('whirlpool', $password); return hash('whirlpool', $password);
} }
@ -724,7 +724,7 @@ class User
* @return string * @return string
* @throws Exception * @throws Exception
*/ */
public static function hashPassword(string $password): string public static function hashPassword($password)
{ {
if (!trim($password)) { if (!trim($password)) {
throw new Exception(DI::l10n()->t('Password can\'t be empty')); throw new Exception(DI::l10n()->t('Password can\'t be empty'));
@ -741,7 +741,7 @@ class User
* @return bool * @return bool
* @throws Exception * @throws Exception
*/ */
public static function updatePassword(int $uid, string $password): bool public static function updatePassword($uid, $password)
{ {
$password = trim($password); $password = trim($password);
@ -771,7 +771,7 @@ class User
* @return bool * @return bool
* @throws Exception * @throws Exception
*/ */
private static function updatePasswordHashed(int $uid, string $pasword_hashed): bool private static function updatePasswordHashed($uid, $pasword_hashed)
{ {
$fields = [ $fields = [
'password' => $pasword_hashed, 'password' => $pasword_hashed,
@ -792,7 +792,7 @@ class User
* @param string $nickname The nickname that should be checked * @param string $nickname The nickname that should be checked
* @return boolean True is the nickname is blocked on the node * @return boolean True is the nickname is blocked on the node
*/ */
public static function isNicknameBlocked(string $nickname): bool public static function isNicknameBlocked($nickname)
{ {
$forbidden_nicknames = DI::config()->get('system', 'forbidden_nicknames', ''); $forbidden_nicknames = DI::config()->get('system', 'forbidden_nicknames', '');
if (!empty($forbidden_nicknames)) { if (!empty($forbidden_nicknames)) {
@ -829,7 +829,7 @@ class User
* @return string avatar link * @return string avatar link
* @throws Exception * @throws Exception
*/ */
public static function getAvatarUrl(array $user, string $size = ''): string public static function getAvatarUrl(array $user, string $size = ''):string
{ {
if (empty($user['nickname'])) { if (empty($user['nickname'])) {
DI::logger()->warning('Missing user nickname key', ['trace' => System::callstack(20)]); DI::logger()->warning('Missing user nickname key', ['trace' => System::callstack(20)]);
@ -871,7 +871,7 @@ class User
* @return string banner link * @return string banner link
* @throws Exception * @throws Exception
*/ */
public static function getBannerUrl(array $user): string public static function getBannerUrl(array $user):string
{ {
if (empty($user['nickname'])) { if (empty($user['nickname'])) {
DI::logger()->warning('Missing user nickname key', ['trace' => System::callstack(20)]); DI::logger()->warning('Missing user nickname key', ['trace' => System::callstack(20)]);
@ -913,7 +913,7 @@ class User
* @throws ImagickException * @throws ImagickException
* @throws Exception * @throws Exception
*/ */
public static function create(array $data): array public static function create(array $data)
{ {
$return = ['user' => null, 'password' => '']; $return = ['user' => null, 'password' => ''];
@ -1255,7 +1255,7 @@ class User
* @throws Exception * @throws Exception
*/ */
public static function block(int $uid, bool $block = true): bool public static function block(int $uid, bool $block = true)
{ {
return DBA::update('user', ['blocked' => $block], ['uid' => $uid]); return DBA::update('user', ['blocked' => $block], ['uid' => $uid]);
} }
@ -1270,7 +1270,7 @@ class User
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
* @throws Exception * @throws Exception
*/ */
public static function allow(string $hash): bool public static function allow(string $hash)
{ {
$register = Register::getByHash($hash); $register = Register::getByHash($hash);
if (!DBA::isResult($register)) { if (!DBA::isResult($register)) {
@ -1316,7 +1316,7 @@ class User
* @return bool True, if the deny was successfull * @return bool True, if the deny was successfull
* @throws Exception * @throws Exception
*/ */
public static function deny(string $hash): bool public static function deny(string $hash)
{ {
$register = Register::getByHash($hash); $register = Register::getByHash($hash);
if (!DBA::isResult($register)) { if (!DBA::isResult($register)) {
@ -1348,7 +1348,7 @@ class User
* @throws ErrorException * @throws ErrorException
* @throws ImagickException * @throws ImagickException
*/ */
public static function createMinimal(string $name, string $email, string $nick, string $lang = L10n::DEFAULT): bool public static function createMinimal(string $name, string $email, string $nick, string $lang = L10n::DEFAULT)
{ {
if (empty($name) || if (empty($name) ||
empty($email) || empty($email) ||
@ -1418,7 +1418,7 @@ class User
* @return NULL|boolean from notification() and email() inherited * @return NULL|boolean from notification() and email() inherited
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
public static function sendRegisterPendingEmail(array $user, string $sitename, string $siteurl, string $password) public static function sendRegisterPendingEmail($user, $sitename, $siteurl, $password)
{ {
$body = Strings::deindent(DI::l10n()->t( $body = Strings::deindent(DI::l10n()->t(
' '
@ -1461,7 +1461,7 @@ class User
* @return NULL|boolean from notification() and email() inherited * @return NULL|boolean from notification() and email() inherited
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
public static function sendRegisterOpenEmail(L10n $l10n, array $user, string $sitename, string $siteurl, string $password) public static function sendRegisterOpenEmail(L10n $l10n, $user, $sitename, $siteurl, $password)
{ {
$preamble = Strings::deindent($l10n->t( $preamble = Strings::deindent($l10n->t(
' '
@ -1520,7 +1520,7 @@ class User
* @return bool * @return bool
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
public static function remove(int $uid): bool public static function remove(int $uid)
{ {
if (empty($uid)) { if (empty($uid)) {
return false; return false;
@ -1574,7 +1574,7 @@ class User
* ] * ]
* @throws Exception * @throws Exception
*/ */
public static function identities(int $uid): array public static function identities($uid)
{ {
if (empty($uid)) { if (empty($uid)) {
return []; return [];
@ -1646,7 +1646,7 @@ class User
* @param int $uid * @param int $uid
* @return bool * @return bool
*/ */
public static function hasIdentities(int $uid): bool public static function hasIdentities(int $uid):bool
{ {
if (empty($uid)) { if (empty($uid)) {
return false; return false;
@ -1679,7 +1679,7 @@ class User
* *
* @throws Exception * @throws Exception
*/ */
public static function getStatistics(): array public static function getStatistics()
{ {
$statistics = [ $statistics = [
'total_users' => 0, 'total_users' => 0,
@ -1732,10 +1732,10 @@ class User
* @param string $order Order of the user list (Default is 'contact.name') * @param string $order Order of the user list (Default is 'contact.name')
* @param bool $descending Order direction (Default is ascending) * @param bool $descending Order direction (Default is ascending)
* *
* @return array|bool The list of the users * @return array The list of the users
* @throws Exception * @throws Exception
*/ */
public static function getList(int $start = 0, int $count = Pager::ITEMS_PER_PAGE, string $type = 'all', string $order = 'name', bool $descending = false) public static function getList($start = 0, $count = Pager::ITEMS_PER_PAGE, $type = 'all', $order = 'name', bool $descending = false)
{ {
$param = ['limit' => [$start, $count], 'order' => [$order => $descending]]; $param = ['limit' => [$start, $count], 'order' => [$order => $descending]];
$condition = []; $condition = [];

View file

@ -48,7 +48,7 @@ class BaseSettings extends BaseModule
'label' => DI::l10n()->t('Two-factor authentication'), 'label' => DI::l10n()->t('Two-factor authentication'),
'url' => 'settings/2fa', 'url' => 'settings/2fa',
'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === '2fa') ? 'active' : ''), 'selected' => ((DI::args()->getArgc() > 1) && (DI::args()->getArgv()[1] === '2fa') ? 'active' : ''),
'accesskey' => '2', 'accesskey' => 'o',
]; ];
$tabs[] = [ $tabs[] = [

View file

@ -59,13 +59,12 @@ class Notify extends BaseModule
} }
} }
private static function dispatchPublic(array $postdata) private static function dispatchPublic($postdata)
{ {
$msg = Diaspora::decodeRaw($postdata, '', true); $msg = Diaspora::decodeRaw($postdata, '', true);
if (!is_array($msg)) { if (!$msg) {
// We have to fail silently to be able to hand it over to the salmon parser // We have to fail silently to be able to hand it over to the salmon parser
Logger::warning('Diaspora::decodeRaw() has failed for some reason.'); return false;
return;
} }
// Fetch the corresponding public contact // Fetch the corresponding public contact
@ -89,10 +88,10 @@ class Notify extends BaseModule
System::xmlExit($ret, 'Done'); System::xmlExit($ret, 'Done');
} }
private static function dispatchPrivate(array $user, string $postdata) private static function dispatchPrivate($user, $postdata)
{ {
$msg = Diaspora::decodeRaw($postdata, $user['prvkey'] ?? ''); $msg = Diaspora::decodeRaw($postdata, $user['prvkey'] ?? '');
if (!is_array($msg)) { if (!$msg) {
System::xmlExit(4, 'Unable to parse message'); System::xmlExit(4, 'Unable to parse message');
} }

View file

@ -34,6 +34,6 @@ class Poll extends BaseModule
protected function rawContent(array $request = []) protected function rawContent(array $request = [])
{ {
$last_update = $request['last_update'] ?? ''; $last_update = $request['last_update'] ?? '';
System::httpExit(OStatus::feed($this->parameters['nickname'], $last_update, 10) ?? '', Response::TYPE_ATOM); System::httpExit(OStatus::feed($this->parameters['nickname'], $last_update, 10), Response::TYPE_ATOM);
} }
} }

View file

@ -112,7 +112,7 @@ class Directory extends BaseModule
* *
* @throws \Exception * @throws \Exception
*/ */
public static function formatEntry(array $contact, string $photo_size = 'photo'): array public static function formatEntry(array $contact, $photo_size = 'photo')
{ {
$itemurl = (($contact['addr'] != "") ? $contact['addr'] : $contact['url']); $itemurl = (($contact['addr'] != "") ? $contact['addr'] : $contact['url']);
@ -166,7 +166,7 @@ class Directory extends BaseModule
'img_hover' => $contact['name'], 'img_hover' => $contact['name'],
'name' => $contact['name'], 'name' => $contact['name'],
'details' => $details, 'details' => $details,
'account_type' => Model\Contact::getAccountType($contact['contact-type'] ?? 0), 'account_type' => Model\Contact::getAccountType($contact['contact-type']),
'profile' => $profile, 'profile' => $profile,
'location' => $location_e, 'location' => $location_e,
'tags' => $contact['pub_keywords'], 'tags' => $contact['pub_keywords'],

View file

@ -128,7 +128,7 @@ class Photo extends BaseModule
throw new HTTPException\NotFoundException(DI::l10n()->t('The Photo is not available.')); throw new HTTPException\NotFoundException(DI::l10n()->t('The Photo is not available.'));
} }
$photo = self::getPhotoById($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL); $photo = self::getPhotoByid($id, $this->parameters['type'], $customsize ?: Proxy::PIXEL_SMALL);
} else { } else {
$photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME); $photoid = pathinfo($this->parameters['name'], PATHINFO_FILENAME);
$scale = 0; $scale = 0;
@ -228,18 +228,10 @@ class Photo extends BaseModule
System::exit(); System::exit();
} }
/** private static function getPhotoByid(int $id, $type, $customsize)
* Fetches photo record by given id number, type and custom size
*
* @param int $id Photo id
* @param string $type Photo type
* @param int $customsize Custom size (?)
* @return array|bool Array on success, false on error
*/
private static function getPhotoById(int $id, string $type, int $customsize)
{ {
switch($type) { switch($type) {
case 'preview': case "preview":
$media = DBA::selectFirst('post-media', ['preview', 'url', 'mimetype', 'type', 'uri-id'], ['id' => $id]); $media = DBA::selectFirst('post-media', ['preview', 'url', 'mimetype', 'type', 'uri-id'], ['id' => $id]);
if (empty($media)) { if (empty($media)) {
return false; return false;
@ -259,7 +251,7 @@ class Photo extends BaseModule
} }
return MPhoto::createPhotoForExternalResource($url, (int)local_user(), $media['mimetype']); return MPhoto::createPhotoForExternalResource($url, (int)local_user(), $media['mimetype']);
case 'media': case "media":
$media = DBA::selectFirst('post-media', ['url', 'mimetype', 'uri-id'], ['id' => $id, 'type' => Post\Media::IMAGE]); $media = DBA::selectFirst('post-media', ['url', 'mimetype', 'uri-id'], ['id' => $id, 'type' => Post\Media::IMAGE]);
if (empty($media)) { if (empty($media)) {
return false; return false;
@ -270,15 +262,15 @@ class Photo extends BaseModule
} }
return MPhoto::createPhotoForExternalResource($media['url'], (int)local_user(), $media['mimetype']); return MPhoto::createPhotoForExternalResource($media['url'], (int)local_user(), $media['mimetype']);
case 'link': case "link":
$link = DBA::selectFirst('post-link', ['url', 'mimetype'], ['id' => $id]); $link = DBA::selectFirst('post-link', ['url', 'mimetype'], ['id' => $id]);
if (empty($link)) { if (empty($link)) {
return false; return false;
} }
return MPhoto::createPhotoForExternalResource($link['url'], (int)local_user(), $link['mimetype']); return MPhoto::createPhotoForExternalResource($link['url'], (int)local_user(), $link['mimetype']);
case 'contact': case "contact":
$fields = ['uid', 'uri-id', 'url', 'nurl', 'avatar', 'photo', 'xmpp', 'addr', 'network', 'failed', 'updated']; $fields = ['uid', 'url', 'nurl', 'avatar', 'photo', 'xmpp', 'addr', 'network', 'failed', 'updated'];
$contact = Contact::getById($id, $fields); $contact = Contact::getById($id, $fields);
if (empty($contact)) { if (empty($contact)) {
return false; return false;
@ -295,7 +287,7 @@ class Photo extends BaseModule
} else { } else {
$scale = 4; $scale = 4;
} }
$photo = MPhoto::selectFirst([], ['scale' => $scale, 'uid' => $contact['uid'], 'profile' => 1]); $photo = MPhoto::selectFirst([], ["scale" => $scale, "uid" => $contact['uid'], "profile" => 1]);
if (!empty($photo)) { if (!empty($photo)) {
return $photo; return $photo;
} }
@ -338,7 +330,7 @@ class Photo extends BaseModule
} }
if ($update) { if ($update) {
Logger::info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]); Logger::info('Invalid file, contact update initiated', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
Worker::add(PRIORITY_LOW, 'UpdateContact', $id); Worker::add(PRIORITY_LOW, "UpdateContact", $id);
} else { } else {
Logger::info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]); Logger::info('Invalid file', ['cid' => $id, 'url' => $contact['url'], 'avatar' => $url]);
} }
@ -360,7 +352,7 @@ class Photo extends BaseModule
} }
} }
return MPhoto::createPhotoForExternalResource($url, 0, $mimetext); return MPhoto::createPhotoForExternalResource($url, 0, $mimetext);
case 'header': case "header":
$fields = ['uid', 'url', 'header', 'network', 'gsid']; $fields = ['uid', 'url', 'header', 'network', 'gsid'];
$contact = Contact::getById($id, $fields); $contact = Contact::getById($id, $fields);
if (empty($contact)) { if (empty($contact)) {
@ -375,37 +367,37 @@ class Photo extends BaseModule
$url = Contact::getDefaultHeader($contact); $url = Contact::getDefaultHeader($contact);
} }
return MPhoto::createPhotoForExternalResource($url); return MPhoto::createPhotoForExternalResource($url);
case 'banner': case "banner":
$photo = MPhoto::selectFirst([], ['scale' => 3, 'uid' => $id, 'photo-type' => MPhoto::USER_BANNER]); $photo = MPhoto::selectFirst([], ["scale" => 3, 'uid' => $id, 'photo-type' => MPhoto::USER_BANNER]);
if (!empty($photo)) { if (!empty($photo)) {
return $photo; return $photo;
} }
return MPhoto::createPhotoForExternalResource(DI::baseUrl() . '/images/friendica-banner.jpg'); return MPhoto::createPhotoForExternalResource(DI::baseUrl() . '/images/friendica-banner.jpg');
case 'profile': case "profile":
case 'custom': case "custom":
$scale = 4; $scale = 4;
break; break;
case 'micro': case "micro":
$scale = 6; $scale = 6;
break; break;
case 'avatar': case "avatar":
default: default:
$scale = 5; $scale = 5;
} }
$photo = MPhoto::selectFirst([], ['scale' => $scale, 'uid' => $id, 'profile' => 1]); $photo = MPhoto::selectFirst([], ["scale" => $scale, "uid" => $id, "profile" => 1]);
if (empty($photo)) { if (empty($photo)) {
$contact = DBA::selectFirst('contact', [], ['uid' => $id, 'self' => true]) ?: []; $contact = DBA::selectFirst('contact', [], ['uid' => $id, 'self' => true]) ?: [];
switch($type) { switch($type) {
case 'profile': case "profile":
case 'custom': case "custom":
$default = Contact::getDefaultAvatar($contact, Proxy::SIZE_SMALL); $default = Contact::getDefaultAvatar($contact, Proxy::SIZE_SMALL);
break; break;
case 'micro': case "micro":
$default = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO); $default = Contact::getDefaultAvatar($contact, Proxy::SIZE_MICRO);
break; break;
case 'avatar': case "avatar":
default: default:
$default = Contact::getDefaultAvatar($contact, Proxy::SIZE_THUMB); $default = Contact::getDefaultAvatar($contact, Proxy::SIZE_THUMB);
} }

View file

@ -33,14 +33,14 @@ interface ICanHandleHttpResponses
* *
* @return string The Return Code * @return string The Return Code
*/ */
public function getReturnCode(): string; public function getReturnCode();
/** /**
* Returns the Content Type * Returns the Content Type
* *
* @return string the Content Type * @return string the Content Type
*/ */
public function getContentType(): string; public function getContentType();
/** /**
* Returns the headers * Returns the headers
@ -55,20 +55,21 @@ interface ICanHandleHttpResponses
/** /**
* Returns all headers * Returns all headers
*
* @see MessageInterface::getHeaders() * @see MessageInterface::getHeaders()
*
* @return string[][] * @return string[][]
*/ */
public function getHeaders(); public function getHeaders();
/** /**
* Check if a specified header exists * Check if a specified header exists
*
* @see MessageInterface::hasHeader() * @see MessageInterface::hasHeader()
*
* @param string $field header field * @param string $field header field
*
* @return boolean "true" if header exists * @return boolean "true" if header exists
*/ */
public function inHeader(string $field): bool; public function inHeader(string $field);
/** /**
* Returns the headers as an associated array * Returns the headers as an associated array
@ -82,22 +83,21 @@ interface ICanHandleHttpResponses
/** /**
* @return bool * @return bool
*/ */
public function isSuccess(): bool; public function isSuccess();
/** /**
* @return string * @return string
*/ */
public function getUrl(): string; public function getUrl();
/** /**
* @return string * @return string
*/ */
public function getRedirectUrl(): string; public function getRedirectUrl();
/** /**
* Getter for body
*
* @see MessageInterface::getBody() * @see MessageInterface::getBody()
*
* @return string * @return string
*/ */
public function getBody(); public function getBody();
@ -105,20 +105,20 @@ interface ICanHandleHttpResponses
/** /**
* @return boolean * @return boolean
*/ */
public function isRedirectUrl(): bool; public function isRedirectUrl();
/** /**
* @return integer * @return integer
*/ */
public function getErrorNumber(): int; public function getErrorNumber();
/** /**
* @return string * @return string
*/ */
public function getError(): string; public function getError();
/** /**
* @return boolean * @return boolean
*/ */
public function isTimeout(): bool; public function isTimeout();
} }

View file

@ -1445,7 +1445,7 @@ class Probe
* @return array|bool OStatus data or "false" on error or "true" on short mode * @return array|bool OStatus data or "false" on error or "true" on short mode
* @throws HTTPException\InternalServerErrorException * @throws HTTPException\InternalServerErrorException
*/ */
private static function ostatus(array $webfinger, bool $short = false) private static function ostatus($webfinger, $short = false)
{ {
$data = []; $data = [];

View file

@ -1008,7 +1008,7 @@ class Post
/** /**
* @return string * @return string
*/ */
private function getRedirectUrl(): string private function getRedirectUrl()
{ {
return $this->redirect_url; return $this->redirect_url;
} }

View file

@ -110,7 +110,7 @@ class ContactResult implements IResult
/** /**
* @return string * @return string
*/ */
public function getUrl(): string public function getUrl()
{ {
return $this->url; return $this->url;
} }

View file

@ -33,9 +33,9 @@ class ProfileFields extends BaseCollection
/** /**
* @param callable $callback * @param callable $callback
* @return ProfileFields (as an extended form of BaseCollection) * @return ProfileFields
*/ */
public function map(callable $callback): BaseCollection public function map(callable $callback): ProfileFields
{ {
return parent::map($callback); return parent::map($callback);
} }
@ -43,9 +43,9 @@ class ProfileFields extends BaseCollection
/** /**
* @param callable|null $callback * @param callable|null $callback
* @param int $flag * @param int $flag
* @return ProfileFields as an extended version of BaseCollection * @return ProfileFields
*/ */
public function filter(callable $callback = null, int $flag = 0): BaseCollection public function filter(callable $callback = null, int $flag = 0): ProfileFields
{ {
return parent::filter($callback, $flag); return parent::filter($callback, $flag);
} }

View file

@ -212,7 +212,7 @@ final class Activity
* *
* @return bool True, if the activity is hidden * @return bool True, if the activity is hidden
*/ */
public function isHidden(string $activity): bool public function isHidden(string $activity)
{ {
foreach (self::HIDDEN_ACTIVITIES as $hiddenActivity) { foreach (self::HIDDEN_ACTIVITIES as $hiddenActivity) {
if ($this->match($activity, $hiddenActivity)) { if ($this->match($activity, $hiddenActivity)) {
@ -231,7 +231,7 @@ final class Activity
* *
* @return boolean * @return boolean
*/ */
public function match(string $haystack, string $needle): bool public function match(string $haystack, string $needle)
{ {
return (($haystack === $needle) || return (($haystack === $needle) ||
((basename($needle) === $haystack) && ((basename($needle) === $haystack) &&

View file

@ -104,12 +104,12 @@ class ActivityPub
* @return array * @return array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function fetchContent(string $url, int $uid = 0): array public static function fetchContent(string $url, int $uid = 0)
{ {
return HTTPSignature::fetch($url, $uid); return HTTPSignature::fetch($url, $uid);
} }
private static function getAccountType(array $apcontact): int private static function getAccountType($apcontact)
{ {
$accounttype = -1; $accounttype = -1;
@ -146,7 +146,7 @@ class ActivityPub
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function probeProfile(string $url, bool $update = true): array public static function probeProfile($url, $update = true)
{ {
$apcontact = APContact::getByURL($url, $update); $apcontact = APContact::getByURL($url, $update);
if (empty($apcontact)) { if (empty($apcontact)) {
@ -204,7 +204,7 @@ class ActivityPub
* @param integer $uid User ID * @param integer $uid User ID
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function fetchOutbox(string $url, int $uid) public static function fetchOutbox($url, $uid)
{ {
$data = self::fetchContent($url, $uid); $data = self::fetchContent($url, $uid);
if (empty($data)) { if (empty($data)) {
@ -235,7 +235,7 @@ class ActivityPub
* @param integer $uid Optional user id * @param integer $uid Optional user id
* @return array Endpoint items * @return array Endpoint items
*/ */
public static function fetchItems(string $url, int $uid = 0): array public static function fetchItems(string $url, int $uid = 0)
{ {
$data = self::fetchContent($url, $uid); $data = self::fetchContent($url, $uid);
if (empty($data)) { if (empty($data)) {
@ -268,7 +268,7 @@ class ActivityPub
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isSupportedByContactUrl(string $url, $update = null) public static function isSupportedByContactUrl($url, $update = null)
{ {
return !empty(APContact::getByURL($url, $update)); return !empty(APContact::getByURL($url, $update));
} }

View file

@ -71,7 +71,7 @@ class Processor
* @param array $languages * @param array $languages
* @return string language JSON * @return string language JSON
*/ */
private static function processLanguages(array $languages): string private static function processLanguages(array $languages)
{ {
$codes = array_keys($languages); $codes = array_keys($languages);
$lang = []; $lang = [];
@ -88,13 +88,12 @@ class Processor
/** /**
* Replaces emojis in the body * Replaces emojis in the body
* *
* @param int $uri_id
* @param string $body
* @param array $emojis * @param array $emojis
* @param string $body
* *
* @return string with replaced emojis * @return string with replaced emojis
*/ */
private static function replaceEmojis(int $uri_id, string $body, array $emojis): string private static function replaceEmojis(int $uri_id, $body, array $emojis)
{ {
$body = strtr($body, $body = strtr($body,
array_combine( array_combine(
@ -144,7 +143,7 @@ class Processor
* @param array $activity * @param array $activity
* @param array $item * @param array $item
*/ */
private static function storeAttachments(array $activity, array $item) private static function storeAttachments($activity, $item)
{ {
if (empty($activity['attachments'])) { if (empty($activity['attachments'])) {
return; return;
@ -161,7 +160,7 @@ class Processor
* @param array $activity * @param array $activity
* @param array $item * @param array $item
*/ */
private static function storeQuestion(array $activity, array $item) private static function storeQuestion($activity, $item)
{ {
if (empty($activity['question'])) { if (empty($activity['question'])) {
return; return;
@ -192,7 +191,7 @@ class Processor
* @param array $activity Activity array * @param array $activity Activity array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function updateItem(array $activity) public static function updateItem($activity)
{ {
$item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity', 'post-type'], ['uri' => $activity['id']]); $item = Post::selectFirst(['uri', 'uri-id', 'thr-parent', 'gravity', 'post-type'], ['uri' => $activity['id']]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
@ -263,7 +262,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function createItem(array $activity): array public static function createItem($activity)
{ {
$item = []; $item = [];
$item['verb'] = Activity::POST; $item['verb'] = Activity::POST;
@ -412,7 +411,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function deleteItem(array $activity) public static function deleteItem($activity)
{ {
$owner = Contact::getIdForURL($activity['actor']); $owner = Contact::getIdForURL($activity['actor']);
@ -427,7 +426,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function addTag(array $activity) public static function addTag($activity)
{ {
if (empty($activity['object_content']) || empty($activity['object_id'])) { if (empty($activity['object_content']) || empty($activity['object_id'])) {
return; return;
@ -458,7 +457,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function createActivity(array $activity, string $verb) public static function createActivity($activity, $verb)
{ {
$item = self::createItem($activity); $item = self::createItem($activity);
if (empty($item)) { if (empty($item)) {
@ -562,7 +561,7 @@ class Processor
* @return int event id * @return int event id
* @throws \Exception * @throws \Exception
*/ */
public static function createEvent(array $activity, array $item): int public static function createEvent($activity, $item)
{ {
$event['summary'] = HTML::toBBCode($activity['name'] ?: $activity['summary']); $event['summary'] = HTML::toBBCode($activity['name'] ?: $activity['summary']);
$event['desc'] = HTML::toBBCode($activity['content']); $event['desc'] = HTML::toBBCode($activity['content']);
@ -606,7 +605,7 @@ class Processor
* @return array|bool Returns the item array or false if there was an unexpected occurrence * @return array|bool Returns the item array or false if there was an unexpected occurrence
* @throws \Exception * @throws \Exception
*/ */
private static function processContent(array $activity, array $item) private static function processContent($activity, $item)
{ {
if (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/markdown')) { if (!empty($activity['mediatype']) && ($activity['mediatype'] == 'text/markdown')) {
$item['title'] = strip_tags($activity['name']); $item['title'] = strip_tags($activity['name']);
@ -616,8 +615,8 @@ class Processor
$content = $activity['content']; $content = $activity['content'];
} else { } else {
// By default assume "text/html" // By default assume "text/html"
$item['title'] = HTML::toBBCode($activity['name'] ?? ''); $item['title'] = HTML::toBBCode($activity['name']);
$content = HTML::toBBCode($activity['content'] ?? ''); $content = HTML::toBBCode($activity['content']);
} }
$item['title'] = trim(BBCode::toPlaintext($item['title'])); $item['title'] = trim(BBCode::toPlaintext($item['title']));
@ -651,7 +650,7 @@ class Processor
$content = self::removeImplicitMentionsFromBody($content, $parent); $content = self::removeImplicitMentionsFromBody($content, $parent);
} }
$item['content-warning'] = HTML::toBBCode($activity['summary'] ?? ''); $item['content-warning'] = HTML::toBBCode($activity['summary']);
$item['raw-body'] = $item['body'] = $content; $item['raw-body'] = $item['body'] = $content;
} }
@ -690,7 +689,7 @@ class Processor
* @param string $url message URL * @param string $url message URL
* @return string with GUID * @return string with GUID
*/ */
private static function getGUIDByURL(string $url): string private static function getGUIDByURL(string $url)
{ {
$parsed = parse_url($url); $parsed = parse_url($url);
@ -711,7 +710,7 @@ class Processor
* @param array $item * @param array $item
* @return boolean Is the message wanted? * @return boolean Is the message wanted?
*/ */
private static function isSolicitedMessage(array $activity, array $item): bool private static function isSolicitedMessage(array $activity, array $item)
{ {
// The checks are split to improve the support when searching why a message was accepted. // The checks are split to improve the support when searching why a message was accepted.
if (count($activity['receiver']) != 1) { if (count($activity['receiver']) != 1) {
@ -972,7 +971,7 @@ class Processor
* @return int|bool New mail table row id or false on error * @return int|bool New mail table row id or false on error
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function postMail(array $activity, array $item) private static function postMail($activity, $item)
{ {
if (($item['gravity'] != GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) { if (($item['gravity'] != GRAVITY_PARENT) && !DBA::exists('mail', ['uri' => $item['thr-parent'], 'uid' => $item['uid']])) {
Logger::info('Parent not found, mail will be discarded.', ['uid' => $item['uid'], 'uri' => $item['thr-parent']]); Logger::info('Parent not found, mail will be discarded.', ['uid' => $item['uid'], 'uri' => $item['thr-parent']]);
@ -1113,7 +1112,7 @@ class Processor
* @return string fetched message URL * @return string fetched message URL
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function fetchMissingActivity(string $url, array $child = [], string $relay_actor = '', int $completion = Receiver::COMPLETION_MANUAL): string public static function fetchMissingActivity(string $url, array $child = [], string $relay_actor = '', int $completion = Receiver::COMPLETION_MANUAL)
{ {
if (!empty($child['receiver'])) { if (!empty($child['receiver'])) {
$uid = ActivityPub\Receiver::getFirstUserFromReceivers($child['receiver']); $uid = ActivityPub\Receiver::getFirstUserFromReceivers($child['receiver']);
@ -1208,7 +1207,7 @@ class Processor
* @param string $id object ID * @param string $id object ID
* @return boolean true if message is accepted * @return boolean true if message is accepted
*/ */
private static function acceptIncomingMessage(array $activity, string $id): bool private static function acceptIncomingMessage(array $activity, string $id)
{ {
if (empty($activity['as:object'])) { if (empty($activity['as:object'])) {
Logger::info('No object field in activity - accepted', ['id' => $id]); Logger::info('No object field in activity - accepted', ['id' => $id]);
@ -1216,7 +1215,7 @@ class Processor
} }
$replyto = JsonLD::fetchElement($activity['as:object'], 'as:inReplyTo', '@id'); $replyto = JsonLD::fetchElement($activity['as:object'], 'as:inReplyTo', '@id');
$uriid = ItemURI::getIdByURI($replyto ?? ''); $uriid = ItemURI::getIdByURI($replyto);
if (Post::exists(['uri-id' => $uriid])) { if (Post::exists(['uri-id' => $uriid])) {
Logger::info('Post is a reply to an existing post - accepted', ['id' => $id, 'uri-id' => $uriid, 'replyto' => $replyto]); Logger::info('Post is a reply to an existing post - accepted', ['id' => $id, 'uri-id' => $uriid, 'replyto' => $replyto]);
return true; return true;
@ -1225,7 +1224,7 @@ class Processor
$attributed_to = JsonLD::fetchElement($activity['as:object'], 'as:attributedTo', '@id'); $attributed_to = JsonLD::fetchElement($activity['as:object'], 'as:attributedTo', '@id');
$authorid = Contact::getIdForURL($attributed_to); $authorid = Contact::getIdForURL($attributed_to);
$body = HTML::toBBCode(JsonLD::fetchElement($activity['as:object'], 'as:content', '@value') ?? ''); $body = HTML::toBBCode(JsonLD::fetchElement($activity['as:object'], 'as:content', '@value'));
$messageTags = []; $messageTags = [];
$tags = Receiver::processTags(JsonLD::fetchElementArray($activity['as:object'], 'as:tag') ?? []); $tags = Receiver::processTags(JsonLD::fetchElementArray($activity['as:object'], 'as:tag') ?? []);
@ -1248,7 +1247,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function followUser(array $activity) public static function followUser($activity)
{ {
$uid = User::getIdForURL($activity['object_id']); $uid = User::getIdForURL($activity['object_id']);
if (empty($uid)) { if (empty($uid)) {
@ -1326,7 +1325,7 @@ class Processor
* @param array $activity * @param array $activity
* @throws \Exception * @throws \Exception
*/ */
public static function updatePerson(array $activity) public static function updatePerson($activity)
{ {
if (empty($activity['object_id'])) { if (empty($activity['object_id'])) {
return; return;
@ -1342,7 +1341,7 @@ class Processor
* @param array $activity * @param array $activity
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function deletePerson(array $activity) public static function deletePerson($activity)
{ {
if (empty($activity['object_id']) || empty($activity['actor'])) { if (empty($activity['object_id']) || empty($activity['actor'])) {
Logger::info('Empty object id or actor.'); Logger::info('Empty object id or actor.');
@ -1369,7 +1368,7 @@ class Processor
* @param array $activity * @param array $activity
* @throws \Exception * @throws \Exception
*/ */
public static function blockAccount(array $activity) public static function blockAccount($activity)
{ {
$cid = Contact::getIdForURL($activity['actor']); $cid = Contact::getIdForURL($activity['actor']);
if (empty($cid)) { if (empty($cid)) {
@ -1392,7 +1391,7 @@ class Processor
* @param array $activity * @param array $activity
* @throws \Exception * @throws \Exception
*/ */
public static function unblockAccount(array $activity) public static function unblockAccount($activity)
{ {
$cid = Contact::getIdForURL($activity['actor']); $cid = Contact::getIdForURL($activity['actor']);
if (empty($cid)) { if (empty($cid)) {
@ -1416,7 +1415,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function acceptFollowUser(array $activity) public static function acceptFollowUser($activity)
{ {
$uid = User::getIdForURL($activity['object_actor']); $uid = User::getIdForURL($activity['object_actor']);
if (empty($uid)) { if (empty($uid)) {
@ -1450,7 +1449,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function rejectFollowUser(array $activity) public static function rejectFollowUser($activity)
{ {
$uid = User::getIdForURL($activity['object_actor']); $uid = User::getIdForURL($activity['object_actor']);
if (empty($uid)) { if (empty($uid)) {
@ -1483,7 +1482,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function undoActivity(array $activity) public static function undoActivity($activity)
{ {
if (empty($activity['object_id'])) { if (empty($activity['object_id'])) {
return; return;
@ -1508,7 +1507,7 @@ class Processor
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function undoFollowUser(array $activity) public static function undoFollowUser($activity)
{ {
$uid = User::getIdForURL($activity['object_object']); $uid = User::getIdForURL($activity['object_object']);
if (empty($uid)) { if (empty($uid)) {
@ -1543,7 +1542,7 @@ class Processor
* @param integer $cid Contact ID * @param integer $cid Contact ID
* @throws \Exception * @throws \Exception
*/ */
private static function switchContact(int $cid) private static function switchContact($cid)
{ {
$contact = DBA::selectFirst('contact', ['network', 'url'], ['id' => $cid]); $contact = DBA::selectFirst('contact', ['network', 'url'], ['id' => $cid]);
if (!DBA::isResult($contact) || in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN]) || Contact::isLocal($contact['url'])) { if (!DBA::isResult($contact) || in_array($contact['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN]) || Contact::isLocal($contact['url'])) {
@ -1563,7 +1562,7 @@ class Processor
* @return array * @return array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function getImplicitMentionList(array $parent): array private static function getImplicitMentionList(array $parent)
{ {
$parent_terms = Tag::getByURIId($parent['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]); $parent_terms = Tag::getByURIId($parent['uri-id'], [Tag::MENTION, Tag::IMPLICIT_MENTION, Tag::EXCLUSIVE_MENTION]);
@ -1601,7 +1600,7 @@ class Processor
* @param array $parent * @param array $parent
* @return string * @return string
*/ */
private static function removeImplicitMentionsFromBody(string $body, array $parent): string private static function removeImplicitMentionsFromBody(string $body, array $parent)
{ {
if (DI::config()->get('system', 'disable_implicit_mentions')) { if (DI::config()->get('system', 'disable_implicit_mentions')) {
return $body; return $body;

View file

@ -84,9 +84,8 @@ class Receiver
* @param $header * @param $header
* @param integer $uid User ID * @param integer $uid User ID
* @throws \Exception * @throws \Exception
* @todo Find type for $body/$header
*/ */
public static function processInbox($body, $header, int $uid) public static function processInbox($body, $header, $uid)
{ {
$activity = json_decode($body, true); $activity = json_decode($body, true);
if (empty($activity)) { if (empty($activity)) {
@ -221,11 +220,11 @@ class Receiver
* @param string $object_id Object ID of the the provided object * @param string $object_id Object ID of the the provided object
* @param integer $uid User ID * @param integer $uid User ID
* *
* @return string with object type or NULL * @return string with object type
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function fetchObjectType(array $activity, string $object_id, int $uid = 0) private static function fetchObjectType($activity, $object_id, $uid = 0)
{ {
if (!empty($activity['as:object'])) { if (!empty($activity['as:object'])) {
$object_type = JsonLD::fetchElement($activity['as:object'], '@type'); $object_type = JsonLD::fetchElement($activity['as:object'], '@type');
@ -269,7 +268,7 @@ class Receiver
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function prepareObjectData(array $activity, int $uid, bool $push, bool &$trust_source): array public static function prepareObjectData($activity, $uid, $push, &$trust_source)
{ {
$id = JsonLD::fetchElement($activity, '@id'); $id = JsonLD::fetchElement($activity, '@id');
if (!empty($id) && !$trust_source) { if (!empty($id) && !$trust_source) {
@ -459,7 +458,7 @@ class Receiver
* @param array $receivers Array with receivers * @param array $receivers Array with receivers
* @return integer user id; * @return integer user id;
*/ */
public static function getFirstUserFromReceivers(array $receivers): int public static function getFirstUserFromReceivers($receivers)
{ {
foreach ($receivers as $receiver) { foreach ($receivers as $receiver) {
if (!empty($receiver)) { if (!empty($receiver)) {
@ -480,7 +479,7 @@ class Receiver
* @param array $signer The signer of the post * @param array $signer The signer of the post
* @throws \Exception * @throws \Exception
*/ */
public static function processActivity(array $activity, string $body = '', int $uid = null, bool $trust_source = false, bool $push = false, array $signer = []) public static function processActivity($activity, string $body = '', int $uid = null, bool $trust_source = false, bool $push = false, array $signer = [])
{ {
$type = JsonLD::fetchElement($activity, '@type'); $type = JsonLD::fetchElement($activity, '@type');
if (!$type) { if (!$type) {
@ -819,7 +818,7 @@ class Receiver
* *
* @return int user id * @return int user id
*/ */
public static function getBestUserForActivity(array $activity): int public static function getBestUserForActivity(array $activity)
{ {
$uid = 0; $uid = 0;
$actor = JsonLD::fetchElement($activity, 'as:actor', '@id') ?? ''; $actor = JsonLD::fetchElement($activity, 'as:actor', '@id') ?? '';
@ -845,8 +844,7 @@ class Receiver
return $uid; return $uid;
} }
// @TODO Missing documentation public static function getReceiverURL($activity)
public static function getReceiverURL(array $activity): array
{ {
$urls = []; $urls = [];
@ -878,9 +876,9 @@ class Receiver
* @return array with receivers (user id) * @return array with receivers (user id)
* @throws \Exception * @throws \Exception
*/ */
private static function getReceivers(array $activity, string $actor, array $tags = [], bool $fetch_unlisted = false): array private static function getReceivers($activity, $actor, $tags = [], $fetch_unlisted = false)
{ {
$reply = $receivers = $profile = []; $reply = $receivers = [];
// When it is an answer, we inherite the receivers from the parent // When it is an answer, we inherite the receivers from the parent
$replyto = JsonLD::fetchElement($activity, 'as:inReplyTo', '@id'); $replyto = JsonLD::fetchElement($activity, 'as:inReplyTo', '@id');
@ -1007,7 +1005,7 @@ class Receiver
* @return array with receivers (user id) * @return array with receivers (user id)
* @throws \Exception * @throws \Exception
*/ */
private static function getReceiverForActor(string $actor, array $tags, array $receivers, int $target_type, array $profile): array private static function getReceiverForActor($actor, $tags, $receivers, $target_type, $profile)
{ {
$basecondition = ['rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER], $basecondition = ['rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER],
'network' => Protocol::FEDERATED, 'archive' => false, 'pending' => false]; 'network' => Protocol::FEDERATED, 'archive' => false, 'pending' => false];
@ -1049,12 +1047,13 @@ class Receiver
* Tests if the contact is a valid receiver for this actor * Tests if the contact is a valid receiver for this actor
* *
* @param array $contact * @param array $contact
* @param string $actor
* @param array $tags * @param array $tags
* *
* @return bool with receivers (user id) * @return bool with receivers (user id)
* @throws \Exception * @throws \Exception
*/ */
private static function isValidReceiverForActor(array $contact, array $tags): bool private static function isValidReceiverForActor($contact, $tags)
{ {
// Are we following the contact? Then this is a valid receiver // Are we following the contact? Then this is a valid receiver
if (in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND])) { if (in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND])) {
@ -1090,7 +1089,7 @@ class Receiver
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function switchContact(int $cid, int $uid, string $url) public static function switchContact($cid, $uid, $url)
{ {
if (DBA::exists('contact', ['id' => $cid, 'network' => Protocol::ACTIVITYPUB])) { if (DBA::exists('contact', ['id' => $cid, 'network' => Protocol::ACTIVITYPUB])) {
Logger::info('Contact is already ActivityPub', ['id' => $cid, 'uid' => $uid, 'url' => $url]); Logger::info('Contact is already ActivityPub', ['id' => $cid, 'uid' => $uid, 'url' => $url]);
@ -1109,7 +1108,7 @@ class Receiver
} }
/** /**
* @TODO Fix documentation and type-hints *
* *
* @param $receivers * @param $receivers
* @param $actor * @param $actor
@ -1136,14 +1135,14 @@ class Receiver
} }
/** /**
* @TODO Fix documentation and type-hints *
* *
* @param $object_data * @param $object_data
* @param array $activity * @param array $activity
* *
* @return mixed * @return mixed
*/ */
private static function addActivityFields($object_data, array $activity) private static function addActivityFields($object_data, $activity)
{ {
if (!empty($activity['published']) && empty($object_data['published'])) { if (!empty($activity['published']) && empty($object_data['published'])) {
$object_data['published'] = JsonLD::fetchElement($activity, 'as:published', '@value'); $object_data['published'] = JsonLD::fetchElement($activity, 'as:published', '@value');
@ -1263,7 +1262,7 @@ class Receiver
* @param array $languages * @param array $languages
* @return array Languages * @return array Languages
*/ */
public static function processLanguages(array $languages): array public static function processLanguages(array $languages)
{ {
if (empty($languages)) { if (empty($languages)) {
return []; return [];
@ -1286,7 +1285,7 @@ class Receiver
* *
* @return array with tags in a simplified format * @return array with tags in a simplified format
*/ */
public static function processTags(array $tags): array public static function processTags(array $tags)
{ {
$taglist = []; $taglist = [];
@ -1318,7 +1317,7 @@ class Receiver
* @param array $emojis * @param array $emojis
* @return array with emojis in a simplified format * @return array with emojis in a simplified format
*/ */
private static function processEmojis(array $emojis): array private static function processEmojis(array $emojis)
{ {
$emojilist = []; $emojilist = [];
@ -1344,7 +1343,7 @@ class Receiver
* *
* @return array Attachments in a simplified format * @return array Attachments in a simplified format
*/ */
private static function processAttachments(array $attachments): array private static function processAttachments(array $attachments)
{ {
$attachlist = []; $attachlist = [];
@ -1461,7 +1460,7 @@ class Receiver
* *
* @return array Questions in a simplified format * @return array Questions in a simplified format
*/ */
private static function processQuestion(array $object): array private static function processQuestion(array $object)
{ {
$question = []; $question = [];
@ -1519,10 +1518,10 @@ class Receiver
* @param array $object * @param array $object
* @param array $object_data * @param array $object_data
* *
* @return array Object data (?) * @return array
* @throws \Exception * @throws \Exception
*/ */
private static function getSource(array $object, array $object_data): array private static function getSource($object, $object_data)
{ {
$object_data['source'] = JsonLD::fetchElement($object, 'as:source', 'as:content', 'as:mediaType', 'text/bbcode'); $object_data['source'] = JsonLD::fetchElement($object, 'as:source', 'as:content', 'as:mediaType', 'text/bbcode');
$object_data['source'] = JsonLD::fetchElement($object_data, 'source', '@value'); $object_data['source'] = JsonLD::fetchElement($object_data, 'source', '@value');
@ -1651,10 +1650,10 @@ class Receiver
* *
* @param array $object * @param array $object
* *
* @return array|bool Object data or FALSE if $object does not contain @id element * @return array
* @throws \Exception * @throws \Exception
*/ */
private static function processObject(array $object) private static function processObject($object)
{ {
if (!JsonLD::fetchElement($object, '@id')) { if (!JsonLD::fetchElement($object, '@id')) {
return false; return false;
@ -1768,7 +1767,7 @@ class Receiver
$object_data['question'] = self::processQuestion($object); $object_data['question'] = self::processQuestion($object);
} }
$receiverdata = self::getReceivers($object, $object_data['actor'] ?? '', $object_data['tags'], true); $receiverdata = self::getReceivers($object, $object_data['actor'], $object_data['tags'], true);
$receivers = $reception_types = []; $receivers = $reception_types = [];
foreach ($receiverdata as $key => $data) { foreach ($receiverdata as $key => $data) {
$receivers[$key] = $data['uid']; $receivers[$key] = $data['uid'];

View file

@ -68,7 +68,7 @@ class Transmitter
* @param array $inboxes * @param array $inboxes
* @return array inboxes with added relay servers * @return array inboxes with added relay servers
*/ */
public static function addRelayServerInboxes(array $inboxes = []): array public static function addRelayServerInboxes(array $inboxes = [])
{ {
foreach (Relay::getList(['inbox']) as $contact) { foreach (Relay::getList(['inbox']) as $contact) {
$inboxes[$contact['inbox']] = $contact['inbox']; $inboxes[$contact['inbox']] = $contact['inbox'];
@ -83,7 +83,7 @@ class Transmitter
* @param array $inboxes * @param array $inboxes
* @return array inboxes with added relay servers * @return array inboxes with added relay servers
*/ */
public static function addRelayServerInboxesForItem(int $item_id, array $inboxes = []): array public static function addRelayServerInboxesForItem(int $item_id, array $inboxes = [])
{ {
$item = Post::selectFirst(['uid'], ['id' => $item_id]); $item = Post::selectFirst(['uid'], ['id' => $item_id]);
if (empty($item)) { if (empty($item)) {

View file

@ -72,7 +72,7 @@ class DFRN
* @return array importer * @return array importer
* @throws \Exception * @throws \Exception
*/ */
public static function getImporter(int $cid, int $uid = 0): array public static function getImporter($cid, $uid = 0)
{ {
$condition = ['id' => $cid, 'blocked' => false, 'pending' => false]; $condition = ['id' => $cid, 'blocked' => false, 'pending' => false];
$contact = DBA::selectFirst('contact', [], $condition); $contact = DBA::selectFirst('contact', [], $condition);
@ -115,7 +115,7 @@ class DFRN
* @throws \ImagickException * @throws \ImagickException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
public static function entries(array $items, array $owner): string public static function entries($items, $owner)
{ {
$doc = new DOMDocument('1.0', 'utf-8'); $doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true; $doc->formatOutput = true;
@ -152,7 +152,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function itemFeed(int $uri_id, int $uid, bool $conversation = false): string public static function itemFeed(int $uri_id, int $uid, bool $conversation = false)
{ {
if ($conversation) { if ($conversation) {
$condition = ['parent-uri-id' => $uri_id]; $condition = ['parent-uri-id' => $uri_id];
@ -222,7 +222,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
public static function mail(array $mail, array $owner): string public static function mail(array $mail, array $owner)
{ {
$doc = new DOMDocument('1.0', 'utf-8'); $doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true; $doc->formatOutput = true;
@ -259,7 +259,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
public static function fsuggest(array $item, array $owner): string public static function fsuggest($item, $owner)
{ {
$doc = new DOMDocument('1.0', 'utf-8'); $doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true; $doc->formatOutput = true;
@ -289,7 +289,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
public static function relocate(array $owner, int $uid): string public static function relocate($owner, $uid)
{ {
/* get site pubkey. this could be a new installation with no site keys*/ /* get site pubkey. this could be a new installation with no site keys*/
@ -346,9 +346,9 @@ class DFRN
* *
* @return object XML root object * @return object XML root object
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hint for returned type * @todo Find proper type-hints
*/ */
private static function addHeader(DOMDocument $doc, array $owner, string $authorelement, string $alternatelink = '', bool $public = false) private static function addHeader(DOMDocument $doc, $owner, $authorelement, $alternatelink = "", $public = false)
{ {
if ($alternatelink == "") { if ($alternatelink == "") {
@ -428,12 +428,8 @@ class DFRN
* viewer's timezone also, but first we are going to convert it from the birthday * viewer's timezone also, but first we are going to convert it from the birthday
* person's timezone to GMT - so the viewer may find the birthday starting at * person's timezone to GMT - so the viewer may find the birthday starting at
* 6:00PM the day before, but that will correspond to midnight to the birthday person. * 6:00PM the day before, but that will correspond to midnight to the birthday person.
*
* @param int $uid User id
* @param string $tz Time zone string, like UTC
* @return string Formatted birthday string
*/ */
private static function determineNextBirthday(int $uid, string $tz): string private static function determineNextBirthday($uid, $tz)
{ {
$birthday = ''; $birthday = '';
@ -471,7 +467,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
private static function addAuthor(DOMDocument $doc, array $owner, string $authorelement, bool $public) private static function addAuthor(DOMDocument $doc, array $owner, $authorelement, $public)
{ {
// Should the profile be "unsearchable" in the net? Then add the "hide" element // Should the profile be "unsearchable" in the net? Then add the "hide" element
$hide = DBA::exists('profile', ['uid' => $owner['uid'], 'net-publish' => false]); $hide = DBA::exists('profile', ['uid' => $owner['uid'], 'net-publish' => false]);
@ -596,7 +592,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
private static function addEntryAuthor(DOMDocument $doc, string $element, string $contact_url, array $item) private static function addEntryAuthor(DOMDocument $doc, $element, $contact_url, $item)
{ {
$author = $doc->createElement($element); $author = $doc->createElement($element);
@ -641,7 +637,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
private static function createActivity(DOMDocument $doc, string $element, string $activity, int $uriid) private static function createActivity(DOMDocument $doc, $element, $activity, $uriid)
{ {
if ($activity) { if ($activity) {
$entry = $doc->createElement($element); $entry = $doc->createElement($element);
@ -707,7 +703,7 @@ class DFRN
* @return void XML attachment object * @return void XML attachment object
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
private static function getAttachment($doc, $root, array $item) private static function getAttachment($doc, $root, $item)
{ {
foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT, Post\Media::UNKNOWN]) as $attachment) { foreach (Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT, Post\Media::TORRENT, Post\Media::UNKNOWN]) as $attachment) {
$attributes = ['rel' => 'enclosure', $attributes = ['rel' => 'enclosure',
@ -741,7 +737,7 @@ class DFRN
* @throws \ImagickException * @throws \ImagickException
* @todo Find proper type-hints * @todo Find proper type-hints
*/ */
private static function entry(DOMDocument $doc, string $type, array $item, array $owner, bool $comment = false, int $cid = 0, bool $single = false) private static function entry(DOMDocument $doc, $type, array $item, array $owner, $comment = false, $cid = 0, $single = false)
{ {
$mentioned = []; $mentioned = [];
@ -965,12 +961,13 @@ class DFRN
* @param array $owner Owner record * @param array $owner Owner record
* @param array $contact Contact record of the receiver * @param array $contact Contact record of the receiver
* @param string $atom Content that will be transmitted * @param string $atom Content that will be transmitted
*
* @param bool $public_batch * @param bool $public_batch
* @return int Deliver status. Negative values mean an error. * @return int Deliver status. Negative values mean an error.
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function transmit(array $owner, array $contact, string $atom, bool $public_batch = false) public static function transmit($owner, $contact, $atom, $public_batch = false)
{ {
if (!$public_batch) { if (!$public_batch) {
if (empty($contact['addr'])) { if (empty($contact['addr'])) {
@ -1063,7 +1060,7 @@ class DFRN
* @throws \ImagickException * @throws \ImagickException
* @todo Find good type-hints for all parameter * @todo Find good type-hints for all parameter
*/ */
private static function fetchauthor(\DOMXPath $xpath, \DOMNode $context, array $importer, string $element, bool $onlyfetch, string $xml = ''): array private static function fetchauthor(\DOMXPath $xpath, \DOMNode $context, $importer, $element, $onlyfetch, $xml = "")
{ {
$author = []; $author = [];
$author["name"] = XML::getFirstNodeValue($xpath, $element."/atom:name/text()", $context); $author["name"] = XML::getFirstNodeValue($xpath, $element."/atom:name/text()", $context);
@ -1283,7 +1280,7 @@ class DFRN
* @return string XML string * @return string XML string
* @todo Find good type-hints for all parameter * @todo Find good type-hints for all parameter
*/ */
private static function transformActivity($xpath, $activity, string $element): string private static function transformActivity($xpath, $activity, $element)
{ {
if (!is_object($activity)) { if (!is_object($activity)) {
return ""; return "";
@ -1338,7 +1335,7 @@ class DFRN
* @throws \Exception * @throws \Exception
* @todo Find good type-hints for all parameter * @todo Find good type-hints for all parameter
*/ */
private static function processMail($xpath, $mail, array $importer) private static function processMail($xpath, $mail, $importer)
{ {
Logger::notice("Processing mails"); Logger::notice("Processing mails");
@ -1367,7 +1364,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo Find good type-hints for all parameter * @todo Find good type-hints for all parameter
*/ */
private static function processSuggestion($xpath, $suggestion, array $importer) private static function processSuggestion($xpath, $suggestion, $importer)
{ {
Logger::notice('Processing suggestions'); Logger::notice('Processing suggestions');
@ -1386,7 +1383,7 @@ class DFRN
* @param integer $from_cid * @param integer $from_cid
* @return bool Was the adding successful? * @return bool Was the adding successful?
*/ */
private static function addSuggestion(int $uid, int $cid, int $from_cid, string $note = ''): bool private static function addSuggestion(int $uid, int $cid, int $from_cid, string $note = '')
{ {
$owner = User::getOwnerDataById($uid); $owner = User::getOwnerDataById($uid);
$contact = Contact::getById($cid); $contact = Contact::getById($cid);
@ -1443,7 +1440,7 @@ class DFRN
* @throws \ImagickException * @throws \ImagickException
* @todo Find good type-hints for all parameter * @todo Find good type-hints for all parameter
*/ */
private static function processRelocation($xpath, $relocation, array $importer): bool private static function processRelocation($xpath, $relocation, $importer)
{ {
Logger::notice("Processing relocations"); Logger::notice("Processing relocations");
@ -1513,7 +1510,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo set proper type-hints (array?) * @todo set proper type-hints (array?)
*/ */
private static function updateContent(array $current, array $item, array $importer, int $entrytype) private static function updateContent($current, $item, $importer, $entrytype)
{ {
$changed = false; $changed = false;
@ -1545,7 +1542,7 @@ class DFRN
* @throws \Exception * @throws \Exception
* @todo set proper type-hints (array?) * @todo set proper type-hints (array?)
*/ */
private static function getEntryType(array $importer, array $item): int private static function getEntryType($importer, $item)
{ {
if ($item["thr-parent"] != $item["uri"]) { if ($item["thr-parent"] != $item["uri"]) {
$community = false; $community = false;
@ -1641,7 +1638,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @todo set proper type-hints (array?) * @todo set proper type-hints (array?)
*/ */
private static function processVerbs(int $entrytype, array $importer, array &$item, bool &$is_like) private static function processVerbs($entrytype, $importer, &$item, &$is_like)
{ {
Logger::info("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype); Logger::info("Process verb ".$item["verb"]." and object-type ".$item["object-type"]." for entrytype ".$entrytype);
@ -1737,7 +1734,7 @@ class DFRN
* @return void * @return void
* @todo set proper type-hints * @todo set proper type-hints
*/ */
private static function parseLinks($links, array &$item) private static function parseLinks($links, &$item)
{ {
$rel = ""; $rel = "";
$href = ""; $href = "";
@ -1775,7 +1772,7 @@ class DFRN
* @param array $imporer * @param array $imporer
* @return boolean Is the message wanted? * @return boolean Is the message wanted?
*/ */
private static function isSolicitedMessage(array $item, array $importer): bool private static function isSolicitedMessage(array $item, array $importer)
{ {
if (DBA::exists('contact', ["`nurl` = ? AND `uid` != ? AND `rel` IN (?, ?)", if (DBA::exists('contact', ["`nurl` = ? AND `uid` != ? AND `rel` IN (?, ?)",
Strings::normaliseLink($item["author-link"]), 0, Contact::FRIEND, Contact::SHARING])) { Strings::normaliseLink($item["author-link"]), 0, Contact::FRIEND, Contact::SHARING])) {
@ -1810,13 +1807,12 @@ class DFRN
* @param object $entry entry elements * @param object $entry entry elements
* @param array $importer Record of the importer user mixed with contact of the content * @param array $importer Record of the importer user mixed with contact of the content
* @param string $xml xml * @param string $xml xml
* @param int $protocol Protocol
* @return void * @return void
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
* @todo Add type-hints * @todo Add type-hints
*/ */
private static function processEntry(array $header, $xpath, $entry, array $importer, string $xml, int $protocol) private static function processEntry($header, $xpath, $entry, $importer, $xml, $protocol)
{ {
Logger::notice("Processing entries"); Logger::notice("Processing entries");
@ -2074,9 +2070,6 @@ class DFRN
} }
} }
// Need to initialize variable, otherwise E_NOTICE will happen
$is_like = false;
if (!self::processVerbs($entrytype, $importer, $item, $is_like)) { if (!self::processVerbs($entrytype, $importer, $item, $is_like)) {
Logger::info("Exiting because 'processVerbs' told us so"); Logger::info("Exiting because 'processVerbs' told us so");
return; return;
@ -2170,7 +2163,7 @@ class DFRN
* @throws \Exception * @throws \Exception
* @todo set proper type-hints * @todo set proper type-hints
*/ */
private static function processDeletion($xpath, $deletion, array $importer) private static function processDeletion($xpath, $deletion, $importer)
{ {
Logger::notice("Processing deletions"); Logger::notice("Processing deletions");
$uri = null; $uri = null;
@ -2231,8 +2224,9 @@ class DFRN
* @return integer Import status * @return integer Import status
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
* @todo set proper type-hints
*/ */
public static function import(string $xml, array $importer, int $protocol, int $direction): int public static function import($xml, $importer, $protocol, $direction)
{ {
if ($xml == "") { if ($xml == "") {
return 400; return 400;
@ -2371,7 +2365,7 @@ class DFRN
* *
* @return string activity verb * @return string activity verb
*/ */
private static function constructVerb(array $item): string private static function constructVerb(array $item)
{ {
if ($item['verb']) { if ($item['verb']) {
return $item['verb']; return $item['verb'];
@ -2379,8 +2373,7 @@ class DFRN
return Activity::POST; return Activity::POST;
} }
// @TODO Documentation missing private static function tgroupCheck($uid, $item)
private static function tgroupCheck(int $uid, array $item): bool
{ {
$mention = false; $mention = false;
@ -2428,12 +2421,12 @@ class DFRN
* item is assumed to be up-to-date. If the timestamps are equal it * item is assumed to be up-to-date. If the timestamps are equal it
* assumes the update has been seen before and should be ignored. * assumes the update has been seen before and should be ignored.
* *
* @param array $existing * @param $existing
* @param array $update * @param $update
* @return bool * @return bool
* @throws \Exception * @throws \Exception
*/ */
private static function isEditedTimestampNewer(array $existing, array $update): bool private static function isEditedTimestampNewer($existing, $update)
{ {
if (empty($existing['edited'])) { if (empty($existing['edited'])) {
return true; return true;
@ -2456,7 +2449,7 @@ class DFRN
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
public static function isSupportedByContactUrl(string $url): bool public static function isSupportedByContactUrl($url)
{ {
$probe = Probe::uri($url, Protocol::DFRN); $probe = Probe::uri($url, Protocol::DFRN);
return $probe['network'] == Protocol::DFRN; return $probe['network'] == Protocol::DFRN;

File diff suppressed because it is too large Load diff

View file

@ -164,7 +164,7 @@ abstract class MailBuilder
* *
* @return string[][] * @return string[][]
*/ */
public function getHeaders(): array public function getHeaders()
{ {
return $this->headers; return $this->headers;
} }
@ -182,7 +182,7 @@ abstract class MailBuilder
* @param string[][] $headers * @param string[][] $headers
* @return $this * @return $this
*/ */
public function withHeaders(array $headers): MailBuilder public function withHeaders(array $headers)
{ {
$this->headers = $headers; $this->headers = $headers;

View file

@ -55,7 +55,7 @@ class HTTPSignature
* @return array with verification data * @return array with verification data
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function verifyMagic(string $key): array public static function verifyMagic($key)
{ {
$headers = null; $headers = null;
$spoofable = false; $spoofable = false;
@ -139,7 +139,7 @@ class HTTPSignature
* *
* @return array * @return array
*/ */
public static function createSig(array $head, string $prvkey, string $keyid = 'Key'): array public static function createSig($head, $prvkey, $keyid = 'Key')
{ {
$return_headers = []; $return_headers = [];
if (!empty($head)) { if (!empty($head)) {
@ -166,7 +166,7 @@ class HTTPSignature
* *
* @return array * @return array
*/ */
private static function sign(array $head, string $prvkey, string $alg = 'sha256'): array private static function sign($head, $prvkey, $alg = 'sha256')
{ {
$ret = []; $ret = [];
$headers = ''; $headers = '';
@ -204,7 +204,7 @@ class HTTPSignature
* - \e string \b signature * - \e string \b signature
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function parseSigheader(string $header): array public static function parseSigheader($header)
{ {
// Remove obsolete folds // Remove obsolete folds
$header = preg_replace('/\n\s+/', ' ', $header); $header = preg_replace('/\n\s+/', ' ', $header);
@ -251,7 +251,7 @@ class HTTPSignature
* @return string Decrypted signature string * @return string Decrypted signature string
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
private static function decryptSigheader(array $headers, string $prvkey): string private static function decryptSigheader(array $headers, string $prvkey)
{ {
if (!empty($headers['iv']) && !empty($headers['key']) && !empty($headers['data'])) { if (!empty($headers['iv']) && !empty($headers['key']) && !empty($headers['data'])) {
return Crypto::unencapsulate($headers, $prvkey); return Crypto::unencapsulate($headers, $prvkey);
@ -341,7 +341,7 @@ class HTTPSignature
* @param boolean $success Transmission status * @param boolean $success Transmission status
* @param boolean $shared The inbox is a shared inbox * @param boolean $shared The inbox is a shared inbox
*/ */
static public function setInboxStatus(string $url, bool $success, bool $shared = false) static public function setInboxStatus($url, $success, $shared = false)
{ {
$now = DateTimeFormat::utcNow(); $now = DateTimeFormat::utcNow();
@ -403,21 +403,21 @@ class HTTPSignature
* @return array JSON array * @return array JSON array
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function fetch(string $request, int $uid): array public static function fetch($request, $uid)
{ {
$curlResult = self::fetchRaw($request, $uid); $curlResult = self::fetchRaw($request, $uid);
if (empty($curlResult)) { if (empty($curlResult)) {
return []; return false;
} }
if (!$curlResult->isSuccess() || empty($curlResult->getBody())) { if (!$curlResult->isSuccess() || empty($curlResult->getBody())) {
return []; return false;
} }
$content = json_decode($curlResult->getBody(), true); $content = json_decode($curlResult->getBody(), true);
if (empty($content) || !is_array($content)) { if (empty($content) || !is_array($content)) {
return []; return false;
} }
return $content; return $content;
@ -438,7 +438,7 @@ class HTTPSignature
* @return \Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses CurlResult * @return \Friendica\Network\HTTPClient\Capability\ICanHandleHttpResponses CurlResult
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function fetchRaw(string $request, int $uid = 0, array $opts = [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::JSON_AS]]) public static function fetchRaw($request, $uid = 0, $opts = [HttpClientOptions::ACCEPT_CONTENT => [HttpClientAccept::JSON_AS]])
{ {
$header = []; $header = [];
@ -488,13 +488,13 @@ class HTTPSignature
/** /**
* Gets a signer from a given HTTP request * Gets a signer from a given HTTP request
* *
* @param string $content * @param $content
* @param array $http_headers * @param $http_headers
* *
* @return string|null|false Signer * @return string Signer
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function getSigner(string $content, array $http_headers) public static function getSigner($content, $http_headers)
{ {
if (empty($http_headers['HTTP_SIGNATURE'])) { if (empty($http_headers['HTTP_SIGNATURE'])) {
Logger::debug('No HTTP_SIGNATURE header'); Logger::debug('No HTTP_SIGNATURE header');
@ -686,13 +686,13 @@ class HTTPSignature
/** /**
* fetches a key for a given id and actor * fetches a key for a given id and actor
* *
* @param string $id * @param $id
* @param string $actor * @param $actor
* *
* @return array with actor url and public key * @return array with actor url and public key
* @throws \Exception * @throws \Exception
*/ */
private static function fetchKey(string $id, string $actor): array private static function fetchKey($id, $actor)
{ {
$url = (strpos($id, '#') ? substr($id, 0, strpos($id, '#')) : $id); $url = (strpos($id, '#') ? substr($id, 0, strpos($id, '#')) : $id);
@ -709,6 +709,6 @@ class HTTPSignature
} }
Logger::notice('Key could not be fetched', ['url' => $url, 'actor' => $actor]); Logger::notice('Key could not be fetched', ['url' => $url, 'actor' => $actor]);
return []; return false;
} }
} }

View file

@ -29,7 +29,7 @@ class Mimetype
* @param string $filename filename * @param string $filename filename
* @return mixed array or string * @return mixed array or string
*/ */
public static function getContentType(string $filename) public static function getContentType($filename)
{ {
$mime_types = [ $mime_types = [

View file

@ -59,7 +59,7 @@ class ParseUrl
* @param string $accept content-type to accept * @param string $accept content-type to accept
* @return array content type * @return array content type
*/ */
public static function getContentType(string $url, string $accept = HttpClientAccept::DEFAULT): array public static function getContentType(string $url, string $accept = HttpClientAccept::DEFAULT)
{ {
$curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => $accept]); $curlResult = DI::httpClient()->head($url, [HttpClientOptions::ACCEPT_CONTENT => $accept]);

View file

@ -165,7 +165,7 @@ class Strings
* @return string Formatted network name * @return string Formatted network name
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function formatNetworkName(string $network, string $url = ''): string public static function formatNetworkName($network, $url = '')
{ {
if ($network != '') { if ($network != '') {
if ($url != '') { if ($url != '') {
@ -176,8 +176,6 @@ class Strings
return $network_name; return $network_name;
} }
return '';
} }
/** /**
@ -189,7 +187,7 @@ class Strings
* *
* @return string Transformed string. * @return string Transformed string.
*/ */
public static function deindent(string $text, string $chr = "[\t ]", int $count = null) public static function deindent($text, $chr = "[\t ]", $count = NULL)
{ {
$lines = explode("\n", $text); $lines = explode("\n", $text);

View file

@ -269,7 +269,7 @@ class Delivery
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function deliverDFRN(string $cmd, array $contact, array $owner, array $items, array $target_item, bool $public_message, bool $top_level, bool $followup, int $server_protocol) private static function deliverDFRN($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup, $server_protocol)
{ {
// Transmit Diaspora reshares via Diaspora if the Friendica contact support Diaspora // Transmit Diaspora reshares via Diaspora if the Friendica contact support Diaspora
if (Diaspora::isReshare($target_item['body'] ?? '') && !empty(FContact::getByURL($contact['addr'], false))) { if (Diaspora::isReshare($target_item['body'] ?? '') && !empty(FContact::getByURL($contact['addr'], false))) {
@ -384,7 +384,7 @@ class Delivery
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function deliverDiaspora(string $cmd, array $contact, array $owner, array $items, array $target_item, bool $public_message, bool $top_level, bool $followup) private static function deliverDiaspora($cmd, $contact, $owner, $items, $target_item, $public_message, $top_level, $followup)
{ {
// We don't treat Forum posts as "wall-to-wall" to be able to post them via Diaspora // We don't treat Forum posts as "wall-to-wall" to be able to post them via Diaspora
$walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Model\User::ACCOUNT_TYPE_COMMUNITY); $walltowall = $top_level && ($owner['id'] != $items[0]['contact-id']) & ($owner['account-type'] != Model\User::ACCOUNT_TYPE_COMMUNITY);
@ -478,7 +478,7 @@ class Delivery
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
* @throws \ImagickException * @throws \ImagickException
*/ */
private static function deliverMail(string $cmd, array $contact, array $owner, array $target_item, array $thr_parent) private static function deliverMail($cmd, $contact, $owner, $target_item, $thr_parent)
{ {
if (DI::config()->get('system','imap_disabled')) { if (DI::config()->get('system','imap_disabled')) {
return; return;

View file

@ -34,7 +34,7 @@ use Friendica\Network\HTTPClient\Client\HttpClientAccept;
*/ */
class Directory class Directory
{ {
public static function execute(string $url = '') public static function execute($url = '')
{ {
$dir = Search::getGlobalDirectory(); $dir = Search::getGlobalDirectory();

View file

@ -30,9 +30,9 @@ class MergeContact
/** /**
* Replace all occurences of the given contact id and replace it * Replace all occurences of the given contact id and replace it
* *
* @param integer $new_cid New contact id * @param integer $new_cid
* @param integer $old_cid Old contact id * @param integer $old_cid
* @param integer $uid User id * @param integer $uid
*/ */
public static function execute(int $new_cid, int $old_cid, int $uid) public static function execute(int $new_cid, int $old_cid, int $uid)
{ {

View file

@ -55,7 +55,7 @@
use Friendica\Database\DBA; use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) { if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1470); define('DB_UPDATE_VERSION', 1469);
} }
return [ return [
@ -1252,12 +1252,12 @@ return [
"fields" => [ "fields" => [
"id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"], "id" => ["type" => "int unsigned", "not null" => "1", "extra" => "auto_increment", "primary" => "1", "comment" => "sequential ID"],
"uri-id" => ["type" => "int unsigned", "not null" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"], "uri-id" => ["type" => "int unsigned", "not null" => "1", "foreign" => ["item-uri" => "id"], "comment" => "Id of the item-uri table entry that contains the item uri"],
"url" => ["type" => "text", "not null" => "1", "comment" => "Media URL"], "url" => ["type" => "varbinary(511)", "not null" => "1", "comment" => "Media URL"],
"type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Media type"], "type" => ["type" => "tinyint unsigned", "not null" => "1", "default" => "0", "comment" => "Media type"],
"mimetype" => ["type" => "varchar(60)", "comment" => ""], "mimetype" => ["type" => "varchar(60)", "comment" => ""],
"height" => ["type" => "smallint unsigned", "comment" => "Height of the media"], "height" => ["type" => "smallint unsigned", "comment" => "Height of the media"],
"width" => ["type" => "smallint unsigned", "comment" => "Width of the media"], "width" => ["type" => "smallint unsigned", "comment" => "Width of the media"],
"size" => ["type" => "mediumint unsigned", "comment" => "Media size"], "size" => ["type" => "int unsigned", "comment" => "Media size"],
"preview" => ["type" => "varbinary(255)", "comment" => "Preview URL"], "preview" => ["type" => "varbinary(255)", "comment" => "Preview URL"],
"preview-height" => ["type" => "smallint unsigned", "comment" => "Height of the preview picture"], "preview-height" => ["type" => "smallint unsigned", "comment" => "Height of the preview picture"],
"preview-width" => ["type" => "smallint unsigned", "comment" => "Width of the preview picture"], "preview-width" => ["type" => "smallint unsigned", "comment" => "Width of the preview picture"],
@ -1272,7 +1272,7 @@ return [
], ],
"indexes" => [ "indexes" => [
"PRIMARY" => ["id"], "PRIMARY" => ["id"],
"uri-id-url" => ["UNIQUE", "uri-id", "url(512)"], "uri-id-url" => ["UNIQUE", "uri-id", "url"],
"uri-id-id" => ["uri-id", "id"], "uri-id-id" => ["uri-id", "id"],
] ]
], ],

View file

@ -122,16 +122,6 @@ return [
// Cache avatar pictures as files (experimental) // Cache avatar pictures as files (experimental)
'avatar_cache' => false, 'avatar_cache' => false,
// avatar_cache_path (String)
// File path to the avatar cache. Default is /(your basepath)/avatar/
// The value has to be an absolute path and has to end with a "/"
'avatar_cache_path' => '',
// avatar_cache_url (String)
// Base URL of the avatar cache. Default is http(s)://(your hostname)/avatar/
// The value has to start with the scheme and end with a "/"
'avatar_cache_url' => '',
// big_emojis (Boolean) // big_emojis (Boolean)
// Display "Emoji Only" posts in big. // Display "Emoji Only" posts in big.
'big_emojis' => false, 'big_emojis' => false,

View file

@ -43,7 +43,7 @@ class AppDouble extends App
$this->isLoggedIn = $isLoggedIn; $this->isLoggedIn = $isLoggedIn;
} }
public function isLoggedIn(): bool public function isLoggedIn()
{ {
return $this->isLoggedIn; return $this->isLoggedIn;
} }

View file

@ -6,9 +6,9 @@
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 2022.09-dev\n" "Project-Id-Version: 2022.06\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-13 05:45+0000\n" "POT-Creation-Date: 2022-06-06 07:33+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -37,7 +37,7 @@ msgstr ""
msgid "User not found." msgid "User not found."
msgstr "" msgstr ""
#: mod/cal.php:122 mod/display.php:262 src/Module/Profile/Profile.php:94 #: mod/cal.php:122 mod/display.php:247 src/Module/Profile/Profile.php:94
#: src/Module/Profile/Profile.php:109 src/Module/Profile/Status.php:110 #: src/Module/Profile/Profile.php:109 src/Module/Profile/Status.php:110
#: src/Module/Update/Profile.php:56 #: src/Module/Update/Profile.php:56
msgid "Access to this profile has been restricted." msgid "Access to this profile has been restricted."
@ -104,17 +104,17 @@ msgstr ""
msgid "calendar" msgid "calendar"
msgstr "" msgstr ""
#: mod/display.php:143 mod/photos.php:802 #: mod/display.php:142 mod/photos.php:802
#: src/Module/Conversation/Community.php:175 src/Module/Directory.php:49 #: src/Module/Conversation/Community.php:175 src/Module/Directory.php:49
#: src/Module/Search/Index.php:50 #: src/Module/Search/Index.php:50
msgid "Public access denied." msgid "Public access denied."
msgstr "" msgstr ""
#: mod/display.php:213 mod/display.php:287 #: mod/display.php:198 mod/display.php:272
msgid "The requested item doesn't exist or has been deleted." msgid "The requested item doesn't exist or has been deleted."
msgstr "" msgstr ""
#: mod/display.php:367 #: mod/display.php:352
msgid "The feed for this item is unavailable." msgid "The feed for this item is unavailable."
msgstr "" msgstr ""
@ -230,7 +230,7 @@ msgstr ""
#: mod/editpost.php:107 mod/message.php:200 mod/message.php:358 #: mod/editpost.php:107 mod/message.php:200 mod/message.php:358
#: mod/photos.php:1489 mod/wallmessage.php:142 src/Content/Conversation.php:368 #: mod/photos.php:1489 mod/wallmessage.php:142 src/Content/Conversation.php:368
#: src/Content/Conversation.php:713 src/Module/Item/Compose.php:177 #: src/Content/Conversation.php:712 src/Module/Item/Compose.php:177
#: src/Object/Post.php:528 #: src/Object/Post.php:528
msgid "Please wait" msgid "Please wait"
msgstr "" msgstr ""
@ -1077,11 +1077,11 @@ msgstr ""
msgid "Comment" msgid "Comment"
msgstr "" msgstr ""
#: mod/photos.php:1424 src/Content/Conversation.php:629 src/Object/Post.php:247 #: mod/photos.php:1424 src/Content/Conversation.php:628 src/Object/Post.php:247
msgid "Select" msgid "Select"
msgstr "" msgstr ""
#: mod/photos.php:1425 mod/settings.php:350 src/Content/Conversation.php:630 #: mod/photos.php:1425 mod/settings.php:350 src/Content/Conversation.php:629
#: src/Module/Admin/Users/Active.php:139 src/Module/Admin/Users/Blocked.php:140 #: src/Module/Admin/Users/Active.php:139 src/Module/Admin/Users/Blocked.php:140
#: src/Module/Admin/Users/Index.php:153 #: src/Module/Admin/Users/Index.php:153
msgid "Delete" msgid "Delete"
@ -1942,7 +1942,7 @@ msgid "%s attends maybe."
msgstr "" msgstr ""
#: src/Content/Conversation.php:222 src/Content/Conversation.php:260 #: src/Content/Conversation.php:222 src/Content/Conversation.php:260
#: src/Content/Conversation.php:873 #: src/Content/Conversation.php:872
#, php-format #, php-format
msgid "%s reshared this." msgid "%s reshared this."
msgstr "" msgstr ""
@ -2061,92 +2061,92 @@ msgstr ""
msgid "Scheduled at" msgid "Scheduled at"
msgstr "" msgstr ""
#: src/Content/Conversation.php:657 src/Object/Post.php:235 #: src/Content/Conversation.php:656 src/Object/Post.php:235
msgid "Pinned item" msgid "Pinned item"
msgstr "" msgstr ""
#: src/Content/Conversation.php:673 src/Object/Post.php:476 #: src/Content/Conversation.php:672 src/Object/Post.php:476
#: src/Object/Post.php:477 #: src/Object/Post.php:477
#, php-format #, php-format
msgid "View %s's profile @ %s" msgid "View %s's profile @ %s"
msgstr "" msgstr ""
#: src/Content/Conversation.php:686 src/Object/Post.php:464 #: src/Content/Conversation.php:685 src/Object/Post.php:464
msgid "Categories:" msgid "Categories:"
msgstr "" msgstr ""
#: src/Content/Conversation.php:687 src/Object/Post.php:465 #: src/Content/Conversation.php:686 src/Object/Post.php:465
msgid "Filed under:" msgid "Filed under:"
msgstr "" msgstr ""
#: src/Content/Conversation.php:695 src/Object/Post.php:490 #: src/Content/Conversation.php:694 src/Object/Post.php:490
#, php-format #, php-format
msgid "%s from %s" msgid "%s from %s"
msgstr "" msgstr ""
#: src/Content/Conversation.php:711 #: src/Content/Conversation.php:710
msgid "View in context" msgid "View in context"
msgstr "" msgstr ""
#: src/Content/Conversation.php:776 #: src/Content/Conversation.php:775
msgid "remove" msgid "remove"
msgstr "" msgstr ""
#: src/Content/Conversation.php:780 #: src/Content/Conversation.php:779
msgid "Delete Selected Items" msgid "Delete Selected Items"
msgstr "" msgstr ""
#: src/Content/Conversation.php:845 src/Content/Conversation.php:848 #: src/Content/Conversation.php:844 src/Content/Conversation.php:847
#: src/Content/Conversation.php:851 src/Content/Conversation.php:854 #: src/Content/Conversation.php:850 src/Content/Conversation.php:853
#, php-format #, php-format
msgid "You had been addressed (%s)." msgid "You had been addressed (%s)."
msgstr "" msgstr ""
#: src/Content/Conversation.php:857 #: src/Content/Conversation.php:856
#, php-format #, php-format
msgid "You are following %s." msgid "You are following %s."
msgstr "" msgstr ""
#: src/Content/Conversation.php:860 #: src/Content/Conversation.php:859
msgid "Tagged" msgid "Tagged"
msgstr "" msgstr ""
#: src/Content/Conversation.php:875 #: src/Content/Conversation.php:874
msgid "Reshared" msgid "Reshared"
msgstr "" msgstr ""
#: src/Content/Conversation.php:875 #: src/Content/Conversation.php:874
#, php-format #, php-format
msgid "Reshared by %s <%s>" msgid "Reshared by %s <%s>"
msgstr "" msgstr ""
#: src/Content/Conversation.php:878 #: src/Content/Conversation.php:877
#, php-format #, php-format
msgid "%s is participating in this thread." msgid "%s is participating in this thread."
msgstr "" msgstr ""
#: src/Content/Conversation.php:881 #: src/Content/Conversation.php:880
msgid "Stored" msgid "Stored"
msgstr "" msgstr ""
#: src/Content/Conversation.php:884 #: src/Content/Conversation.php:883
msgid "Global" msgid "Global"
msgstr "" msgstr ""
#: src/Content/Conversation.php:887 #: src/Content/Conversation.php:886
msgid "Relayed" msgid "Relayed"
msgstr "" msgstr ""
#: src/Content/Conversation.php:887 #: src/Content/Conversation.php:886
#, php-format #, php-format
msgid "Relayed by %s <%s>" msgid "Relayed by %s <%s>"
msgstr "" msgstr ""
#: src/Content/Conversation.php:890 #: src/Content/Conversation.php:889
msgid "Fetched" msgid "Fetched"
msgstr "" msgstr ""
#: src/Content/Conversation.php:890 #: src/Content/Conversation.php:889
#, php-format #, php-format
msgid "Fetched because of %s <%s>" msgid "Fetched because of %s <%s>"
msgstr "" msgstr ""
@ -3625,63 +3625,63 @@ msgstr ""
msgid "Forum" msgid "Forum"
msgstr "" msgstr ""
#: src/Model/Contact.php:2550 #: src/Model/Contact.php:2517
msgid "Disallowed profile URL." msgid "Disallowed profile URL."
msgstr "" msgstr ""
#: src/Model/Contact.php:2555 src/Module/Friendica.php:81 #: src/Model/Contact.php:2522 src/Module/Friendica.php:81
msgid "Blocked domain" msgid "Blocked domain"
msgstr "" msgstr ""
#: src/Model/Contact.php:2560 #: src/Model/Contact.php:2527
msgid "Connect URL missing." msgid "Connect URL missing."
msgstr "" msgstr ""
#: src/Model/Contact.php:2569 #: src/Model/Contact.php:2536
msgid "" msgid ""
"The contact could not be added. Please check the relevant network " "The contact could not be added. Please check the relevant network "
"credentials in your Settings -> Social Networks page." "credentials in your Settings -> Social Networks page."
msgstr "" msgstr ""
#: src/Model/Contact.php:2611 #: src/Model/Contact.php:2578
msgid "The profile address specified does not provide adequate information." msgid "The profile address specified does not provide adequate information."
msgstr "" msgstr ""
#: src/Model/Contact.php:2613 #: src/Model/Contact.php:2580
msgid "No compatible communication protocols or feeds were discovered." msgid "No compatible communication protocols or feeds were discovered."
msgstr "" msgstr ""
#: src/Model/Contact.php:2616 #: src/Model/Contact.php:2583
msgid "An author or name was not found." msgid "An author or name was not found."
msgstr "" msgstr ""
#: src/Model/Contact.php:2619 #: src/Model/Contact.php:2586
msgid "No browser URL could be matched to this address." msgid "No browser URL could be matched to this address."
msgstr "" msgstr ""
#: src/Model/Contact.php:2622 #: src/Model/Contact.php:2589
msgid "" msgid ""
"Unable to match @-style Identity Address with a known protocol or email " "Unable to match @-style Identity Address with a known protocol or email "
"contact." "contact."
msgstr "" msgstr ""
#: src/Model/Contact.php:2623 #: src/Model/Contact.php:2590
msgid "Use mailto: in front of address to force email check." msgid "Use mailto: in front of address to force email check."
msgstr "" msgstr ""
#: src/Model/Contact.php:2629 #: src/Model/Contact.php:2596
msgid "" msgid ""
"The profile address specified belongs to a network which has been disabled " "The profile address specified belongs to a network which has been disabled "
"on this site." "on this site."
msgstr "" msgstr ""
#: src/Model/Contact.php:2634 #: src/Model/Contact.php:2601
msgid "" msgid ""
"Limited profile. This person will be unable to receive direct/personal " "Limited profile. This person will be unable to receive direct/personal "
"notifications from you." "notifications from you."
msgstr "" msgstr ""
#: src/Model/Contact.php:2693 #: src/Model/Contact.php:2660
msgid "Unable to retrieve contact information." msgid "Unable to retrieve contact information."
msgstr "" msgstr ""

File diff suppressed because it is too large Load diff

View file

@ -301,6 +301,9 @@ $a->strings['Dislike'] = 'لم يعجبني';
$a->strings['I don\'t like this (toggle)'] = 'لم يعجبني (بدِّل)'; $a->strings['I don\'t like this (toggle)'] = 'لم يعجبني (بدِّل)';
$a->strings['Map'] = 'خريطة'; $a->strings['Map'] = 'خريطة';
$a->strings['View Album'] = 'اعرض الألبوم'; $a->strings['View Album'] = 'اعرض الألبوم';
$a->strings['{0} wants to be your friend'] = '{0} يريد أن يكون صديقك';
$a->strings['{0} requested registration'] = '{0} طلبَ التسجيل';
$a->strings['{0} and %d others requested registration'] = '{0} و %d أخرون يطلبون التسجيل';
$a->strings['Bad Request.'] = 'طلب خاطئ.'; $a->strings['Bad Request.'] = 'طلب خاطئ.';
$a->strings['Contact not found.'] = 'لم يُعثر على المتراسل.'; $a->strings['Contact not found.'] = 'لم يُعثر على المتراسل.';
$a->strings['[Friendica System Notify]'] = '[تنبيه نظام فرنديكا]'; $a->strings['[Friendica System Notify]'] = '[تنبيه نظام فرنديكا]';
@ -320,6 +323,19 @@ $a->strings['Error'] = [
5 => 'خطأٍ', 5 => 'خطأٍ',
]; ];
$a->strings['Failed to connect with email account using the settings provided.'] = 'فشل الاتصال بحساب البريد الإلكتروني باستخدام الإعدادات المقدمة.'; $a->strings['Failed to connect with email account using the settings provided.'] = 'فشل الاتصال بحساب البريد الإلكتروني باستخدام الإعدادات المقدمة.';
$a->strings['Contact CSV file upload error'] = 'خطأ أثناء رفع ملف CSV';
$a->strings['Importing Contacts done'] = 'أُستورد المتراسلون';
$a->strings['Relocate message has been send to your contacts'] = 'أُرسلت رسالة تنبيه بانتقالك إلى متراسليك';
$a->strings['Passwords do not match.'] = 'كلمتا المرور غير متطابقتين.';
$a->strings['Password update failed. Please try again.'] = 'فشل تحديث كلمة المرور. من فضلك أعد المحاولة.';
$a->strings['Password changed.'] = 'غُيّرت كلمة المرور.';
$a->strings['Password unchanged.'] = 'لم تُغير كلمة المرور.';
$a->strings['Please use a shorter name.'] = 'يرجى استخدام اسم أقصر.';
$a->strings['Name too short.'] = 'الاسم قصير جداً.';
$a->strings['Wrong Password.'] = 'كلمة المرور خاطئة.';
$a->strings['Invalid email.'] = 'البريد الإلكتروني غير صالح.';
$a->strings['Cannot change to that email.'] = 'لا يمكن التغيير إلى هذا البريد الإلكتروني.';
$a->strings['Settings were not updated.'] = 'لم تُحدث الإعدادات.';
$a->strings['Connected Apps'] = 'التطبيقات المتصلة'; $a->strings['Connected Apps'] = 'التطبيقات المتصلة';
$a->strings['Name'] = 'الاسم'; $a->strings['Name'] = 'الاسم';
$a->strings['Home Page'] = 'الصفحة الرئيسية'; $a->strings['Home Page'] = 'الصفحة الرئيسية';
@ -366,6 +382,115 @@ $a->strings['Action after import:'] = 'الإجراء بعد الاستيراد:
$a->strings['Mark as seen'] = 'علّمه كمُشاهَد'; $a->strings['Mark as seen'] = 'علّمه كمُشاهَد';
$a->strings['Move to folder'] = 'انقل إلى مجلد'; $a->strings['Move to folder'] = 'انقل إلى مجلد';
$a->strings['Move to folder:'] = 'انقل إلى المجلد:'; $a->strings['Move to folder:'] = 'انقل إلى المجلد:';
$a->strings['Unable to find your profile. Please contact your admin.'] = 'تعذر العثور على ملفك الشخصي. من فضلك اتصال بالمدير.';
$a->strings['Account Types'] = 'أنواع الحسابات';
$a->strings['Personal Page Subtypes'] = 'الأنواع الفرعية للصفحة الشخصية';
$a->strings['Community Forum Subtypes'] = 'الأنواع الفرعية للمنتدى المجتمعي';
$a->strings['Personal Page'] = 'صفحة شخصية';
$a->strings['Account for a personal profile.'] = 'حساب ملف شخصي خاص.';
$a->strings['Organisation Page'] = 'صفحة منظمة';
$a->strings['Account for an organisation that automatically approves contact requests as "Followers".'] = 'حساب المنظمة يوافق تلقائياً على طلبات المراسلة "كمتابعين".';
$a->strings['News Page'] = 'صفحة إخبارية';
$a->strings['Account for a news reflector that automatically approves contact requests as "Followers".'] = 'حساب إخباري يوافق تلقائياً على طلبات المراسلة "كمتابعين".';
$a->strings['Community Forum'] = 'منتدى مجتمعي';
$a->strings['Account for community discussions.'] = 'حساب مناقشات مجتمعية.';
$a->strings['Normal Account Page'] = 'صفحة حساب عادي';
$a->strings['Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'] = 'حساب ملف شخصي عادي يتطلب الموافقة اليدوية على "الأصدقاء" و "المتابعين".';
$a->strings['Soapbox Page'] = 'صفحة سياسي';
$a->strings['Account for a public profile that automatically approves contact requests as "Followers".'] = 'حساب شخصي علني يوافق تلقائياً على طلبات المراسلة "كمتابعين".';
$a->strings['Public Forum'] = 'منتدى عمومي';
$a->strings['Automatically approves all contact requests.'] = 'يوافق تلقائياً على جميع طلبات المراسلة.';
$a->strings['Automatic Friend Page'] = 'صفحة اشترك تلقائي';
$a->strings['Account for a popular profile that automatically approves contact requests as "Friends".'] = 'حساب ملف شخصي لمشهور يوافق تلقائياً على طلبات المراسلة كـ"أصدقاء".';
$a->strings['Private Forum [Experimental]'] = 'منتدى خاص [تجريبي]';
$a->strings['Requires manual approval of contact requests.'] = 'يتطلب الموافقة اليدوية على طلبات المراسلة.';
$a->strings['OpenID:'] = 'OpenID:';
$a->strings['(Optional) Allow this OpenID to login to this account.'] = '(اختياري) اسمح لمعرف OpenID بالولوج إلى هذا الحساب.';
$a->strings['Publish your profile in your local site directory?'] = 'أتريد نشر ملفك الشخصي في الدليل المحلي للموقع؟';
$a->strings['Your profile will be published in this node\'s <a href="%s">local directory</a>. Your profile details may be publicly visible depending on the system settings.'] = 'سينشر ملفك الشخصي في <a href="%s"> الدليل المحلي</a> لهذه العقدة. تعتمد خصوصية معلوماتك على إعدادات النظام.';
$a->strings['Your profile will also be published in the global friendica directories (e.g. <a href="%s">%s</a>).'] = 'سينشر ملفك الشخصي كذلك في الأدلة العالمية لفرَندِيكا (مثال <a href="%s">%s</a>).';
$a->strings['Your Identity Address is <strong>\'%s\'</strong> or \'%s\'.'] = 'عنوان معرفك هو <strong>\'%s\'</strong> أو \'%s\'.';
$a->strings['Account Settings'] = 'إعدادات الحساب';
$a->strings['Password Settings'] = 'إعدادات كلمة المرور';
$a->strings['New Password:'] = 'كلمة المرور الجديدة:';
$a->strings['Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).'] = 'المحارف المسموح بها هي a-z، A-Z، 0-9 والأحرف الخاصة باستثناء المساحات، الأحرف المنبورة ونقطتي التفسير (:).';
$a->strings['Confirm:'] = 'التأكيد:';
$a->strings['Leave password fields blank unless changing'] = 'اترك حقول كلمة المرور فارغة ما لم ترد تغييرها';
$a->strings['Current Password:'] = 'كلمة المرور الحالية:';
$a->strings['Your current password to confirm the changes'] = 'اكتب كلمة المرور الحالية لتأكيد التغييرات';
$a->strings['Password:'] = 'كلمة المرور:';
$a->strings['Your current password to confirm the changes of the email address'] = 'اكتب كلمة المرور الحالية لتأكيد تغيير بريدك الإلكتروني';
$a->strings['Delete OpenID URL'] = 'احذف معرف OpenID';
$a->strings['Basic Settings'] = 'الإعدادات الأساسيّة';
$a->strings['Full Name:'] = 'الاسم الكامل:';
$a->strings['Email Address:'] = 'البريد الإلكتروني:';
$a->strings['Your Timezone:'] = 'المنطقة الزمنية:';
$a->strings['Your Language:'] = 'لغتك:';
$a->strings['Set the language we use to show you friendica interface and to send you emails'] = 'عيّن لغة واجهة فرَندِيكا ورسائل البريد الإلكتروني';
$a->strings['Default Post Location:'] = 'موقع النشر الافتراضي:';
$a->strings['Use Browser Location:'] = 'استخدم موقع المتصفح:';
$a->strings['Security and Privacy Settings'] = 'إعدادات الأمان والخصوصية';
$a->strings['Maximum Friend Requests/Day:'] = 'حدُ طلبات الصداقة لليوم الواحد:';
$a->strings['(to prevent spam abuse)'] = '(لمنع الرسائل المزعجة)';
$a->strings['Allow your profile to be searchable globally?'] = 'أتريد السماح لملفك الشخصي بالظهور في نتائج البحث العالمي؟';
$a->strings['Activate this setting if you want others to easily find and follow you. Your profile will be searchable on remote systems. This setting also determines whether Friendica will inform search engines that your profile should be indexed or not.'] = 'فعّل هذا الإعداد إن أردت أن يُعثر عليك بسهولة. سيتمكن المستخدمون في المواقع البعيد من العثور عليك، وأيضا سيسمح بظهور ملفك الشخصي في محركات البحث.';
$a->strings['Hide your contact/friend list from viewers of your profile?'] = 'أتريد إخفاء قائمة المتراسلين/الأصدقاء عن متصفحي ملفك الشخصي؟';
$a->strings['A list of your contacts is displayed on your profile page. Activate this option to disable the display of your contact list.'] = 'عادة تُعرض قائمة المتراسلين على صفحة ملفك الشخصي. إن قمت بتفعيل هذا الخيار ستخفى القائمة.';
$a->strings['Hide your profile details from anonymous viewers?'] = 'اخف معلومات ملفك الشخص عن المتصفحين المجهولين؟';
$a->strings['Anonymous visitors will only see your profile picture, your display name and the nickname you are using on your profile page. Your public posts and replies will still be accessible by other means.'] = 'سيرى الزوار المجهولون صورة ملفك الشخصي واسمك العلني ولقبك فقط. لكن ستبقى مشاركتك العامة وردودك متاحة عبر وسائل أخرى.';
$a->strings['Make public posts unlisted'] = 'لا تدرج المشاركات العلنية';
$a->strings['Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.'] = 'لن تظهر مشاركتك العلنية على صفحات المجتمع أو في نتائج البحث لهذا الموقع، ولن يتم إرسالها إلى خوادم الترحيل. غير أنها ستبقى تظهر في التغذيات العمومية للخوادم البعيدة.';
$a->strings['Make all posted pictures accessible'] = 'أتح كل الصور المنشورة';
$a->strings['This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can\'t handle permissions on pictures. Non public pictures still won\'t be visible for the public on your photo albums though.'] = 'يسمح هذا الخيار بالوصول للصورة المنشورة عبر رابط مباشر. هذا حل لمعظم الشبكات التي لا يمكنها التعامل مع الأذونات. صورك غير العلنية ستبقى مخفية.';
$a->strings['Allow friends to post to your profile page?'] = 'أتسمح لأصدقائك بالنشر في صفحة ملفك الشخصي؟';
$a->strings['Your contacts may write posts on your profile wall. These posts will be distributed to your contacts'] = 'يمكن للمتراسلين كتابة مشاركات على حائط ملفك الشخصي. ستكون هذه المشركات مرئية لكل المتراسلين';
$a->strings['Allow friends to tag your posts?'] = 'أتسمح لأصدقائك بوسم مشاركاتك؟';
$a->strings['Your contacts can add additional tags to your posts.'] = 'يمكن لأصدقائك إضافة وسوم لمشاركاتك.';
$a->strings['Permit unknown people to send you private mail?'] = 'أتسمح لأشخاص مجهولين بإرسال بريد خاص لك؟';
$a->strings['Friendica network users may send you private messages even if they are not in your contact list.'] = 'يمكن لمستخدمي شبكة فرَندِكا إرسال رسائل خاصة لك حتى إن لم يكونوا في قائمة المتراسلين.';
$a->strings['Maximum private messages per day from unknown people:'] = 'حد الرسائل اليومي المستلمة من مجهولين:';
$a->strings['Default Post Permissions'] = 'أذونات النشر الافتراضية';
$a->strings['Expiration settings'] = 'إعدادات انتهاء الصلاحية';
$a->strings['Automatically expire posts after this many days:'] = 'أنه صَلاحِيَة المشاركات تلقائياً بعد هذا العدد من الأيام:';
$a->strings['If empty, posts will not expire. Expired posts will be deleted'] = 'إذا كان فارغاً، لن تنتهي صلاحية المشاركات. وإلا بعد المهلة ستحذف المشاركات المنتهية صلاحيتها';
$a->strings['Expire posts'] = 'أنه صَلاحِيَة المشاركات';
$a->strings['When activated, posts and comments will be expired.'] = 'عند تفعيله، ستنهى صلاحية المشاركات والتعليقات.';
$a->strings['Expire personal notes'] = 'أنه صَلاحِيَة الملاحظات الشخصية';
$a->strings['When activated, the personal notes on your profile page will be expired.'] = 'عند تفعيله، ستنهى صلاحية الملاحظات الشخصية على صفحة ملفك الشخصي.';
$a->strings['Expire starred posts'] = 'أنتهي صلاحية المشاركات المفضلة';
$a->strings['Starring posts keeps them from being expired. That behaviour is overwritten by this setting.'] = 'تفضيل مشاركة تقيها من انتهاء الصلاحية. هذا السلوك يُتجاوز من خلال هذا الإعداد.';
$a->strings['Expire photos'] = 'أنه صَلاحِيَة الصور';
$a->strings['When activated, photos will be expired.'] = 'عند تفعيله، ستنهى صلاحية الصور.';
$a->strings['Only expire posts by others'] = 'أنه صَلاحِيَة مشاركات الآخرين فقط';
$a->strings['When activated, your own posts never expire. Then the settings above are only valid for posts you received.'] = 'عند تفعيله، لا نهاية لصلاحية مشاركاتك. ثم تكون الإعدادات أعلاه صالحة فقط للمشاركات التي استلمتها.';
$a->strings['Notification Settings'] = 'إعدادات التنبيهات';
$a->strings['Send a notification email when:'] = 'أرسل تنبيها للبريدي الإلكتروني عند:';
$a->strings['You receive an introduction'] = 'تلقي تقديم';
$a->strings['Your introductions are confirmed'] = 'أُكدت تقديماتك';
$a->strings['Someone writes on your profile wall'] = 'يكتب شخص ما على جدار ملفك الشخصي';
$a->strings['Someone writes a followup comment'] = 'شخص ما يعلق على ما نشرت';
$a->strings['You receive a private message'] = 'تلقي رسالة خاصة';
$a->strings['You receive a friend suggestion'] = 'تلقي اقتراح صداقة';
$a->strings['You are tagged in a post'] = 'ذُكرتَ في مشاركة';
$a->strings['Create a desktop notification when:'] = 'أنشئ تنبيه سطح المكتب عند:';
$a->strings['Someone liked your content'] = 'أُعجب شخص بمحتواك';
$a->strings['Someone shared your content'] = 'شارك شخص محتواك';
$a->strings['Activate desktop notifications'] = 'نشّط تنبيهات سطح المكتب';
$a->strings['Show desktop popup on new notifications'] = 'أظهر منبثقات للتنبيهات الجديدة';
$a->strings['Text-only notification emails'] = 'رسائل تنبيه نصية فقط';
$a->strings['Send text only notification emails, without the html part'] = 'أرسل بريد التنبيه كنص فقط، دون وسوم html';
$a->strings['Show detailled notifications'] = 'اعرض تنبيهات مفصلة';
$a->strings['Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.'] = 'افتراضيًا ، يعرض أحدث تنبيه فقط لكل محادثة. عند تفعيله ستعرض جميع التنبيهات.';
$a->strings['Show notifications of ignored contacts'] = 'أظهر تنبيهات للمتراسلين المتجاهلين';
$a->strings['You don\'t see posts from ignored contacts. But you still see their comments. This setting controls if you want to still receive regular notifications that are caused by ignored contacts or not.'] = 'أنت لا ترى مشاركات المتراسلين المتجاهلين. لكن لا يزال بإمكانك رؤية تعليقاتهم. هذا الإعداد يتحكم إذا كنت ترغب في الاستمرار في تلقي تنبيهات سببها المتراسلون المتجاهلون.';
$a->strings['Advanced Account/Page Type Settings'] = 'الإعدادات المتقدمة للحساب/للصفحة';
$a->strings['Change the behaviour of this account for special situations'] = 'غيّر سلوك هذا الحساب للحالات الخاصة';
$a->strings['Import Contacts'] = 'استيراد متراسلين';
$a->strings['Upload a CSV file that contains the handle of your followed accounts in the first column you exported from the old account.'] = 'ارفع ملف CSV معرفات المتراسلين لحسابك القديم، معرفات المتابَعين تكون في العمود الأول.';
$a->strings['Upload File'] = 'ارفع ملفًا';
$a->strings['Relocate'] = 'الانتقال';
$a->strings['If you have moved this profile from another server, and some of your contacts don\'t receive your updates, try pushing this button.'] = 'إذا كنت قد نقلت هذا الملف الشخصي من خادم آخر، وبعض المتراسلين لا يتلقون تحديثاتك، أنقر هذا الزر.';
$a->strings['Resend relocate message to contacts'] = 'أعد إرسال رسالة الانتقال للمتراسلين';
$a->strings['No suggestions available. If this is a new site, please try again in 24 hours.'] = 'لا توجد اقتراحات متاحة. إذا كان هذا الموقع جديد، من فضلك أعد المحاولة في غضون 24 ساعة.'; $a->strings['No suggestions available. If this is a new site, please try again in 24 hours.'] = 'لا توجد اقتراحات متاحة. إذا كان هذا الموقع جديد، من فضلك أعد المحاولة في غضون 24 ساعة.';
$a->strings['Friend Suggestions'] = 'اقتراحات الأصدقاء'; $a->strings['Friend Suggestions'] = 'اقتراحات الأصدقاء';
$a->strings['photo'] = 'صورة'; $a->strings['photo'] = 'صورة';
@ -426,8 +551,6 @@ $a->strings['Execute pending post updates.'] = 'نفذ التحديثات الم
$a->strings['All pending post updates are done.'] = 'تمت كل تحديثات المعلقة للمشاركة.'; $a->strings['All pending post updates are done.'] = 'تمت كل تحديثات المعلقة للمشاركة.';
$a->strings['Enter user nickname: '] = 'أدخل لقب المستخدم: '; $a->strings['Enter user nickname: '] = 'أدخل لقب المستخدم: ';
$a->strings['Enter new password: '] = 'أدخل كلمة مرور جديدة: '; $a->strings['Enter new password: '] = 'أدخل كلمة مرور جديدة: ';
$a->strings['Password update failed. Please try again.'] = 'فشل تحديث كلمة المرور. من فضلك أعد المحاولة.';
$a->strings['Password changed.'] = 'غُيّرت كلمة المرور.';
$a->strings['Enter user name: '] = 'أدخل اسم المستخدم: '; $a->strings['Enter user name: '] = 'أدخل اسم المستخدم: ';
$a->strings['Enter user email address: '] = 'أدخل عنوان البريد الإلكتروني: '; $a->strings['Enter user email address: '] = 'أدخل عنوان البريد الإلكتروني: ';
$a->strings['Enter a language (optional): '] = 'أدخل اللغة (اختياري): '; $a->strings['Enter a language (optional): '] = 'أدخل اللغة (اختياري): ';
@ -493,7 +616,6 @@ $a->strings['Share'] = 'شارك';
$a->strings['Image'] = 'صورة'; $a->strings['Image'] = 'صورة';
$a->strings['Video'] = 'فيديو'; $a->strings['Video'] = 'فيديو';
$a->strings['Scheduled at'] = 'بُرمِج في'; $a->strings['Scheduled at'] = 'بُرمِج في';
$a->strings['Pinned item'] = 'عنصر مثبت';
$a->strings['View %s\'s profile @ %s'] = 'اعرض ملف %s الشخصي @ %s'; $a->strings['View %s\'s profile @ %s'] = 'اعرض ملف %s الشخصي @ %s';
$a->strings['Categories:'] = 'الفئات:'; $a->strings['Categories:'] = 'الفئات:';
$a->strings['Filed under:'] = 'مصنف كـ:'; $a->strings['Filed under:'] = 'مصنف كـ:';
@ -666,7 +788,6 @@ $a->strings['Archives'] = 'الأرشيفات';
$a->strings['Persons'] = 'الأشخاص'; $a->strings['Persons'] = 'الأشخاص';
$a->strings['Organisations'] = 'المنظّمات'; $a->strings['Organisations'] = 'المنظّمات';
$a->strings['News'] = 'الأخبار'; $a->strings['News'] = 'الأخبار';
$a->strings['Account Types'] = 'أنواع الحسابات';
$a->strings['All'] = 'الكل'; $a->strings['All'] = 'الكل';
$a->strings['Export'] = 'صدّر'; $a->strings['Export'] = 'صدّر';
$a->strings['Export calendar as ical'] = 'صدّر الرزنامة كملف ical'; $a->strings['Export calendar as ical'] = 'صدّر الرزنامة كملف ical';
@ -1130,15 +1251,7 @@ $a->strings['Blocked'] = 'محجوب';
$a->strings['List of blocked users'] = 'قائمة المستخدمين المحجوبين'; $a->strings['List of blocked users'] = 'قائمة المستخدمين المحجوبين';
$a->strings['Deleted'] = 'حُذف'; $a->strings['Deleted'] = 'حُذف';
$a->strings['List of pending user deletions'] = 'قائمة الحذف المعلق للمستخدمين'; $a->strings['List of pending user deletions'] = 'قائمة الحذف المعلق للمستخدمين';
$a->strings['Normal Account Page'] = 'صفحة حساب عادي';
$a->strings['Soapbox Page'] = 'صفحة سياسي';
$a->strings['Public Forum'] = 'منتدى عمومي';
$a->strings['Automatic Friend Page'] = 'صفحة اشترك تلقائي';
$a->strings['Private Forum'] = 'منتدى خاص'; $a->strings['Private Forum'] = 'منتدى خاص';
$a->strings['Personal Page'] = 'صفحة شخصية';
$a->strings['Organisation Page'] = 'صفحة منظمة';
$a->strings['News Page'] = 'صفحة إخبارية';
$a->strings['Community Forum'] = 'منتدى مجتمعي';
$a->strings['Relay'] = 'مُرحِل'; $a->strings['Relay'] = 'مُرحِل';
$a->strings['%s contact unblocked'] = [ $a->strings['%s contact unblocked'] = [
0 => 'لم يُرفع الحجب عن مستخدم %s', 0 => 'لم يُرفع الحجب عن مستخدم %s',
@ -1233,7 +1346,9 @@ $a->strings['Other'] = 'أخرى';
$a->strings['unknown'] = 'مجهول'; $a->strings['unknown'] = 'مجهول';
$a->strings['%s total systems'] = '%s نظام'; $a->strings['%s total systems'] = '%s نظام';
$a->strings['%s active users last month'] = '%s مستخدم نشط في آخر شهر'; $a->strings['%s active users last month'] = '%s مستخدم نشط في آخر شهر';
$a->strings['%s active users last six month'] = '%s مستخدم نشط في آخر ستة أشهر';
$a->strings['%s registered users'] = '%s مستخدم مسجل'; $a->strings['%s registered users'] = '%s مستخدم مسجل';
$a->strings['%s local posts'] = '%s مشاركة محلية';
$a->strings['%s posts per user'] = '%s مشاركة لكل مستخدم'; $a->strings['%s posts per user'] = '%s مشاركة لكل مستخدم';
$a->strings['%s users per system'] = '%s مستخدم لكل نظام'; $a->strings['%s users per system'] = '%s مستخدم لكل نظام';
$a->strings['This page offers you some numbers to the known part of the federated social network your Friendica node is part of. These numbers are not complete but only reflect the part of the network your node is aware of.'] = 'تقدم لك هذه الصفحة بعض الإحصائيات للجزء المعروف من الشبكة الاجتماعية الموحدة المتصلة بعقدتك. هذه الإحصائيات ليست كاملة ولكنها تتضمن المواقع المعروفة لعقدتك من الشبكة.'; $a->strings['This page offers you some numbers to the known part of the federated social network your Friendica node is part of. These numbers are not complete but only reflect the part of the network your node is aware of.'] = 'تقدم لك هذه الصفحة بعض الإحصائيات للجزء المعروف من الشبكة الاجتماعية الموحدة المتصلة بعقدتك. هذه الإحصائيات ليست كاملة ولكنها تتضمن المواقع المعروفة لعقدتك من الشبكة.';
@ -1290,6 +1405,8 @@ $a->strings['ID'] = 'المعرف';
$a->strings['Command'] = 'أمر'; $a->strings['Command'] = 'أمر';
$a->strings['Job Parameters'] = 'معطيات العملية'; $a->strings['Job Parameters'] = 'معطيات العملية';
$a->strings['Priority'] = 'الأولوية'; $a->strings['Priority'] = 'الأولوية';
$a->strings['Can not parse base url. Must have at least <scheme>://<domain>'] = 'يتعذر تحليل الرابط الأساسي. يجب أن يكون <scheme>://<domain>';
$a->strings['Relocation started. Could take a while to complete.'] = 'بدأ النقل. قد يستغرق بعض الوقت.';
$a->strings['No special theme for mobile devices'] = 'لا توجد سمة مخصصة للهاتف'; $a->strings['No special theme for mobile devices'] = 'لا توجد سمة مخصصة للهاتف';
$a->strings['%s - (Experimental)'] = '%s - (اختباري)'; $a->strings['%s - (Experimental)'] = '%s - (اختباري)';
$a->strings['No community page for local users'] = 'لا توجد صفحة مجتمع للمستخدمين المحليين'; $a->strings['No community page for local users'] = 'لا توجد صفحة مجتمع للمستخدمين المحليين';
@ -1320,6 +1437,8 @@ $a->strings['Worker'] = 'مهمة';
$a->strings['Message Relay'] = 'ترحيل الرسالة'; $a->strings['Message Relay'] = 'ترحيل الرسالة';
$a->strings['The system is not subscribed to any relays at the moment.'] = 'هذا الخادم ليس مشترك في أي مرحلات حاليًا.'; $a->strings['The system is not subscribed to any relays at the moment.'] = 'هذا الخادم ليس مشترك في أي مرحلات حاليًا.';
$a->strings['The system is currently subscribed to the following relays:'] = 'هذا الخادم مشترك حاليًا في المرحلات التالية:'; $a->strings['The system is currently subscribed to the following relays:'] = 'هذا الخادم مشترك حاليًا في المرحلات التالية:';
$a->strings['Relocate Instance'] = 'انقل المثيل';
$a->strings['<strong>Warning!</strong> Advanced function. Could make this server unreachable.'] = '<strong>تحذير!</strong> وظيفة متقدمة. يمكن أن تجعل هذا الخادم غير قابل للوصول.';
$a->strings['Site name'] = 'اسم الموقع'; $a->strings['Site name'] = 'اسم الموقع';
$a->strings['Sender Email'] = 'بريد المرسل'; $a->strings['Sender Email'] = 'بريد المرسل';
$a->strings['The email address your server shall use to send notification emails from.'] = 'عنوان البريد الإلكتروني الذي سيستخدمه الخادم لإرسال رسائل التنبيه.'; $a->strings['The email address your server shall use to send notification emails from.'] = 'عنوان البريد الإلكتروني الذي سيستخدمه الخادم لإرسال رسائل التنبيه.';
@ -1335,6 +1454,7 @@ $a->strings['Additional Info'] = 'معلومات إضافية';
$a->strings['For public servers: you can add additional information here that will be listed at %s/servers.'] = 'للخوادم العامة: يمكنك إضافة معلومات إضافية لتدرج في %s/servers.'; $a->strings['For public servers: you can add additional information here that will be listed at %s/servers.'] = 'للخوادم العامة: يمكنك إضافة معلومات إضافية لتدرج في %s/servers.';
$a->strings['System language'] = 'لغة النظام'; $a->strings['System language'] = 'لغة النظام';
$a->strings['System theme'] = 'سمة النظام'; $a->strings['System theme'] = 'سمة النظام';
$a->strings['Default system theme - may be over-ridden by user profiles - <a href="/admin/themes" id="cnftheme">Change default theme settings</a>'] = 'مظهر الموقع الافتراضي يختلف بناءً على الملف الشخصي الذي تمت زيارته - <a href="/admin/themes" id="cnftheme"> غيّر إعدادات السمة الافتراضية</a>';
$a->strings['Mobile system theme'] = 'سمة الهاتف'; $a->strings['Mobile system theme'] = 'سمة الهاتف';
$a->strings['Theme for mobile devices'] = 'سمة للأجهزة المحمولة'; $a->strings['Theme for mobile devices'] = 'سمة للأجهزة المحمولة';
$a->strings['SSL link policy'] = 'سياسة روابط SSL'; $a->strings['SSL link policy'] = 'سياسة روابط SSL';
@ -1435,6 +1555,7 @@ $a->strings['Temp path'] = 'مسار التخزين المؤقت';
$a->strings['If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.'] = 'إذا كان نظامك مقيد حيث لا يستطيع خادم الويب الوصول إلى مسار مجلد التخزين المؤقت (temp)، أدخل مسار آخر هنا.'; $a->strings['If you have a restricted system where the webserver can\'t access the system temp path, enter another path here.'] = 'إذا كان نظامك مقيد حيث لا يستطيع خادم الويب الوصول إلى مسار مجلد التخزين المؤقت (temp)، أدخل مسار آخر هنا.';
$a->strings['Only search in tags'] = 'ابحث في الوسوم فقط'; $a->strings['Only search in tags'] = 'ابحث في الوسوم فقط';
$a->strings['On large systems the text search can slow down the system extremely.'] = 'في النّظم الكبيرة، يمكن أن يؤدي البحث عن النصوص إلى إبطاء النظام.'; $a->strings['On large systems the text search can slow down the system extremely.'] = 'في النّظم الكبيرة، يمكن أن يؤدي البحث عن النصوص إلى إبطاء النظام.';
$a->strings['New base url'] = 'رابط أساسي جديد';
$a->strings['Maximum number of parallel workers'] = 'الحد الأقصى لعدد المهام'; $a->strings['Maximum number of parallel workers'] = 'الحد الأقصى لعدد المهام';
$a->strings['Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.'] = 'إما أن يكون "الكل" أو "الوسوم". يعني "الكل" وُجوب تلقي كل المشاركات العلنية. تعني "الوسوم" وجوب تلقي المشاركات ذات الوسوم المحددة فقط.'; $a->strings['Can be "all" or "tags". "all" means that every public post should be received. "tags" means that only posts with selected tags should be received.'] = 'إما أن يكون "الكل" أو "الوسوم". يعني "الكل" وُجوب تلقي كل المشاركات العلنية. تعني "الوسوم" وجوب تلقي المشاركات ذات الوسوم المحددة فقط.';
$a->strings['Disabled'] = 'معطّل'; $a->strings['Disabled'] = 'معطّل';
@ -1951,8 +2072,6 @@ $a->strings['System Notifications'] = 'تنبيهات النظام';
$a->strings['Personal Notifications'] = 'تنبيهات شخصية'; $a->strings['Personal Notifications'] = 'تنبيهات شخصية';
$a->strings['Home Notifications'] = 'تنبيهات الصفحة الرئيسية'; $a->strings['Home Notifications'] = 'تنبيهات الصفحة الرئيسية';
$a->strings['Show unread'] = 'اعرض غير المقروءة'; $a->strings['Show unread'] = 'اعرض غير المقروءة';
$a->strings['{0} requested registration'] = '{0} طلبَ التسجيل';
$a->strings['{0} and %d others requested registration'] = '{0} و %d أخرون يطلبون التسجيل';
$a->strings['Authorize application connection'] = 'خول لهذا التطبيق الاتصال'; $a->strings['Authorize application connection'] = 'خول لهذا التطبيق الاتصال';
$a->strings['Do you want to authorize this application to access your posts and contacts, and/or create new posts for you?'] = 'هل تخول لهذا التطبيق الوصول إلى مشاركاتك ومتراسليك، و/أو إنشاء مشاركات جديدة باسمك؟'; $a->strings['Do you want to authorize this application to access your posts and contacts, and/or create new posts for you?'] = 'هل تخول لهذا التطبيق الوصول إلى مشاركاتك ومتراسليك، و/أو إنشاء مشاركات جديدة باسمك؟';
$a->strings['Unsupported or missing response type'] = 'نوع الاستجابة غير مدعومة أو مفقودة'; $a->strings['Unsupported or missing response type'] = 'نوع الاستجابة غير مدعومة أو مفقودة';
@ -1970,7 +2089,6 @@ $a->strings['Invalid photo with id %s.'] = 'الصورة ذات المعرف %s
$a->strings['No contacts.'] = 'لا متراسلين.'; $a->strings['No contacts.'] = 'لا متراسلين.';
$a->strings['Profile not found.'] = 'لم يُعثر على الملف الشخصي.'; $a->strings['Profile not found.'] = 'لم يُعثر على الملف الشخصي.';
$a->strings['You\'re currently viewing your profile as <b>%s</b> <a href="%s" class="btn btn-sm pull-right">Cancel</a>'] = 'أنت حاليا تستعرض ملفك الشخصي كـ <b>%s</b><a href="%s" class="btn btn-sm pull-right"> ألغ</a>'; $a->strings['You\'re currently viewing your profile as <b>%s</b> <a href="%s" class="btn btn-sm pull-right">Cancel</a>'] = 'أنت حاليا تستعرض ملفك الشخصي كـ <b>%s</b><a href="%s" class="btn btn-sm pull-right"> ألغ</a>';
$a->strings['Full Name:'] = 'الاسم الكامل:';
$a->strings['Member since:'] = 'عضو منذ:'; $a->strings['Member since:'] = 'عضو منذ:';
$a->strings['j F, Y'] = 'j F, Y'; $a->strings['j F, Y'] = 'j F, Y';
$a->strings['j F'] = 'j F'; $a->strings['j F'] = 'j F';
@ -2003,8 +2121,6 @@ $a->strings['Membership on this site is by invitation only.'] = 'العضوية
$a->strings['Your invitation code: '] = 'رمز الدعوة: '; $a->strings['Your invitation code: '] = 'رمز الدعوة: ';
$a->strings['Your Full Name (e.g. Joe Smith, real or real-looking): '] = 'اسمك الكامل (على سبيل المثال جو سميث): '; $a->strings['Your Full Name (e.g. Joe Smith, real or real-looking): '] = 'اسمك الكامل (على سبيل المثال جو سميث): ';
$a->strings['Please repeat your e-mail address:'] = 'رجاء أعد إدخال عنوان بريدك الإلكتروني:'; $a->strings['Please repeat your e-mail address:'] = 'رجاء أعد إدخال عنوان بريدك الإلكتروني:';
$a->strings['New Password:'] = 'كلمة المرور الجديدة:';
$a->strings['Confirm:'] = 'التأكيد:';
$a->strings['Choose a nickname: '] = 'اختر لقبًا: '; $a->strings['Choose a nickname: '] = 'اختر لقبًا: ';
$a->strings['Import your profile to this friendica instance'] = 'استورد ملفك الشخصي لهذا المثيل'; $a->strings['Import your profile to this friendica instance'] = 'استورد ملفك الشخصي لهذا المثيل';
$a->strings['Parent Password:'] = 'كلمة المرور الولي:'; $a->strings['Parent Password:'] = 'كلمة المرور الولي:';
@ -2052,112 +2168,6 @@ $a->strings['<p>Open the two-factor authentication app on your device to get an
$a->strings['Please enter a code from your authentication app'] = 'يرجى إدخال رمز من تطبيق الاستيثاق'; $a->strings['Please enter a code from your authentication app'] = 'يرجى إدخال رمز من تطبيق الاستيثاق';
$a->strings['This is my two-factor authenticator app device'] = 'هذا هو جهاز الذي استخدمه للاستيثاق بعاملين'; $a->strings['This is my two-factor authenticator app device'] = 'هذا هو جهاز الذي استخدمه للاستيثاق بعاملين';
$a->strings['Verify code and complete login'] = 'تحقق من الرمز وأكمل الولوج'; $a->strings['Verify code and complete login'] = 'تحقق من الرمز وأكمل الولوج';
$a->strings['Passwords do not match.'] = 'كلمتا المرور غير متطابقتين.';
$a->strings['Password unchanged.'] = 'لم تُغير كلمة المرور.';
$a->strings['Please use a shorter name.'] = 'يرجى استخدام اسم أقصر.';
$a->strings['Name too short.'] = 'الاسم قصير جداً.';
$a->strings['Wrong Password.'] = 'كلمة المرور خاطئة.';
$a->strings['Invalid email.'] = 'البريد الإلكتروني غير صالح.';
$a->strings['Cannot change to that email.'] = 'لا يمكن التغيير إلى هذا البريد الإلكتروني.';
$a->strings['Settings were not updated.'] = 'لم تُحدث الإعدادات.';
$a->strings['Contact CSV file upload error'] = 'خطأ أثناء رفع ملف CSV';
$a->strings['Importing Contacts done'] = 'أُستورد المتراسلون';
$a->strings['Relocate message has been send to your contacts'] = 'أُرسلت رسالة تنبيه بانتقالك إلى متراسليك';
$a->strings['Unable to find your profile. Please contact your admin.'] = 'تعذر العثور على ملفك الشخصي. من فضلك اتصال بالمدير.';
$a->strings['Personal Page Subtypes'] = 'الأنواع الفرعية للصفحة الشخصية';
$a->strings['Community Forum Subtypes'] = 'الأنواع الفرعية للمنتدى المجتمعي';
$a->strings['Account for a personal profile.'] = 'حساب ملف شخصي خاص.';
$a->strings['Account for an organisation that automatically approves contact requests as "Followers".'] = 'حساب المنظمة يوافق تلقائياً على طلبات المراسلة "كمتابعين".';
$a->strings['Account for a news reflector that automatically approves contact requests as "Followers".'] = 'حساب إخباري يوافق تلقائياً على طلبات المراسلة "كمتابعين".';
$a->strings['Account for community discussions.'] = 'حساب مناقشات مجتمعية.';
$a->strings['Account for a regular personal profile that requires manual approval of "Friends" and "Followers".'] = 'حساب ملف شخصي عادي يتطلب الموافقة اليدوية على "الأصدقاء" و "المتابعين".';
$a->strings['Account for a public profile that automatically approves contact requests as "Followers".'] = 'حساب شخصي علني يوافق تلقائياً على طلبات المراسلة "كمتابعين".';
$a->strings['Automatically approves all contact requests.'] = 'يوافق تلقائياً على جميع طلبات المراسلة.';
$a->strings['Account for a popular profile that automatically approves contact requests as "Friends".'] = 'حساب ملف شخصي لمشهور يوافق تلقائياً على طلبات المراسلة كـ"أصدقاء".';
$a->strings['Private Forum [Experimental]'] = 'منتدى خاص [تجريبي]';
$a->strings['Requires manual approval of contact requests.'] = 'يتطلب الموافقة اليدوية على طلبات المراسلة.';
$a->strings['OpenID:'] = 'OpenID:';
$a->strings['(Optional) Allow this OpenID to login to this account.'] = '(اختياري) اسمح لمعرف OpenID بالولوج إلى هذا الحساب.';
$a->strings['Publish your profile in your local site directory?'] = 'أتريد نشر ملفك الشخصي في الدليل المحلي للموقع؟';
$a->strings['Your profile will be published in this node\'s <a href="%s">local directory</a>. Your profile details may be publicly visible depending on the system settings.'] = 'سينشر ملفك الشخصي في <a href="%s"> الدليل المحلي</a> لهذه العقدة. تعتمد خصوصية معلوماتك على إعدادات النظام.';
$a->strings['Your profile will also be published in the global friendica directories (e.g. <a href="%s">%s</a>).'] = 'سينشر ملفك الشخصي كذلك في الأدلة العالمية لفرَندِيكا (مثال <a href="%s">%s</a>).';
$a->strings['Account Settings'] = 'إعدادات الحساب';
$a->strings['Your Identity Address is <strong>\'%s\'</strong> or \'%s\'.'] = 'عنوان معرفك هو <strong>\'%s\'</strong> أو \'%s\'.';
$a->strings['Password Settings'] = 'إعدادات كلمة المرور';
$a->strings['Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).'] = 'المحارف المسموح بها هي a-z، A-Z، 0-9 والأحرف الخاصة باستثناء المساحات، الأحرف المنبورة ونقطتي التفسير (:).';
$a->strings['Leave password fields blank unless changing'] = 'اترك حقول كلمة المرور فارغة ما لم ترد تغييرها';
$a->strings['Current Password:'] = 'كلمة المرور الحالية:';
$a->strings['Your current password to confirm the changes'] = 'اكتب كلمة المرور الحالية لتأكيد التغييرات';
$a->strings['Password:'] = 'كلمة المرور:';
$a->strings['Your current password to confirm the changes of the email address'] = 'اكتب كلمة المرور الحالية لتأكيد تغيير بريدك الإلكتروني';
$a->strings['Delete OpenID URL'] = 'احذف معرف OpenID';
$a->strings['Basic Settings'] = 'الإعدادات الأساسيّة';
$a->strings['Email Address:'] = 'البريد الإلكتروني:';
$a->strings['Your Timezone:'] = 'المنطقة الزمنية:';
$a->strings['Your Language:'] = 'لغتك:';
$a->strings['Set the language we use to show you friendica interface and to send you emails'] = 'عيّن لغة واجهة فرَندِيكا ورسائل البريد الإلكتروني';
$a->strings['Default Post Location:'] = 'موقع النشر الافتراضي:';
$a->strings['Use Browser Location:'] = 'استخدم موقع المتصفح:';
$a->strings['Security and Privacy Settings'] = 'إعدادات الأمان والخصوصية';
$a->strings['Maximum Friend Requests/Day:'] = 'حدُ طلبات الصداقة لليوم الواحد:';
$a->strings['(to prevent spam abuse)'] = '(لمنع الرسائل المزعجة)';
$a->strings['Allow your profile to be searchable globally?'] = 'أتريد السماح لملفك الشخصي بالظهور في نتائج البحث العالمي؟';
$a->strings['Activate this setting if you want others to easily find and follow you. Your profile will be searchable on remote systems. This setting also determines whether Friendica will inform search engines that your profile should be indexed or not.'] = 'فعّل هذا الإعداد إن أردت أن يُعثر عليك بسهولة. سيتمكن المستخدمون في المواقع البعيد من العثور عليك، وأيضا سيسمح بظهور ملفك الشخصي في محركات البحث.';
$a->strings['Hide your contact/friend list from viewers of your profile?'] = 'أتريد إخفاء قائمة المتراسلين/الأصدقاء عن متصفحي ملفك الشخصي؟';
$a->strings['A list of your contacts is displayed on your profile page. Activate this option to disable the display of your contact list.'] = 'عادة تُعرض قائمة المتراسلين على صفحة ملفك الشخصي. إن قمت بتفعيل هذا الخيار ستخفى القائمة.';
$a->strings['Hide your profile details from anonymous viewers?'] = 'اخف معلومات ملفك الشخص عن المتصفحين المجهولين؟';
$a->strings['Anonymous visitors will only see your profile picture, your display name and the nickname you are using on your profile page. Your public posts and replies will still be accessible by other means.'] = 'سيرى الزوار المجهولون صورة ملفك الشخصي واسمك العلني ولقبك فقط. لكن ستبقى مشاركتك العامة وردودك متاحة عبر وسائل أخرى.';
$a->strings['Make public posts unlisted'] = 'لا تدرج المشاركات العلنية';
$a->strings['Your public posts will not appear on the community pages or in search results, nor be sent to relay servers. However they can still appear on public feeds on remote servers.'] = 'لن تظهر مشاركتك العلنية على صفحات المجتمع أو في نتائج البحث لهذا الموقع، ولن يتم إرسالها إلى خوادم الترحيل. غير أنها ستبقى تظهر في التغذيات العمومية للخوادم البعيدة.';
$a->strings['Make all posted pictures accessible'] = 'أتح كل الصور المنشورة';
$a->strings['This option makes every posted picture accessible via the direct link. This is a workaround for the problem that most other networks can\'t handle permissions on pictures. Non public pictures still won\'t be visible for the public on your photo albums though.'] = 'يسمح هذا الخيار بالوصول للصورة المنشورة عبر رابط مباشر. هذا حل لمعظم الشبكات التي لا يمكنها التعامل مع الأذونات. صورك غير العلنية ستبقى مخفية.';
$a->strings['Allow friends to post to your profile page?'] = 'أتسمح لأصدقائك بالنشر في صفحة ملفك الشخصي؟';
$a->strings['Your contacts may write posts on your profile wall. These posts will be distributed to your contacts'] = 'يمكن للمتراسلين كتابة مشاركات على حائط ملفك الشخصي. ستكون هذه المشركات مرئية لكل المتراسلين';
$a->strings['Allow friends to tag your posts?'] = 'أتسمح لأصدقائك بوسم مشاركاتك؟';
$a->strings['Your contacts can add additional tags to your posts.'] = 'يمكن لأصدقائك إضافة وسوم لمشاركاتك.';
$a->strings['Permit unknown people to send you private mail?'] = 'أتسمح لأشخاص مجهولين بإرسال بريد خاص لك؟';
$a->strings['Friendica network users may send you private messages even if they are not in your contact list.'] = 'يمكن لمستخدمي شبكة فرَندِكا إرسال رسائل خاصة لك حتى إن لم يكونوا في قائمة المتراسلين.';
$a->strings['Maximum private messages per day from unknown people:'] = 'حد الرسائل اليومي المستلمة من مجهولين:';
$a->strings['Default Post Permissions'] = 'أذونات النشر الافتراضية';
$a->strings['Expiration settings'] = 'إعدادات انتهاء الصلاحية';
$a->strings['Automatically expire posts after this many days:'] = 'أنه صَلاحِيَة المشاركات تلقائياً بعد هذا العدد من الأيام:';
$a->strings['If empty, posts will not expire. Expired posts will be deleted'] = 'إذا كان فارغاً، لن تنتهي صلاحية المشاركات. وإلا بعد المهلة ستحذف المشاركات المنتهية صلاحيتها';
$a->strings['Expire posts'] = 'أنه صَلاحِيَة المشاركات';
$a->strings['When activated, posts and comments will be expired.'] = 'عند تفعيله، ستنهى صلاحية المشاركات والتعليقات.';
$a->strings['Expire personal notes'] = 'أنه صَلاحِيَة الملاحظات الشخصية';
$a->strings['When activated, the personal notes on your profile page will be expired.'] = 'عند تفعيله، ستنهى صلاحية الملاحظات الشخصية على صفحة ملفك الشخصي.';
$a->strings['Expire starred posts'] = 'أنتهي صلاحية المشاركات المفضلة';
$a->strings['Starring posts keeps them from being expired. That behaviour is overwritten by this setting.'] = 'تفضيل مشاركة تقيها من انتهاء الصلاحية. هذا السلوك يُتجاوز من خلال هذا الإعداد.';
$a->strings['Only expire posts by others'] = 'أنه صَلاحِيَة مشاركات الآخرين فقط';
$a->strings['When activated, your own posts never expire. Then the settings above are only valid for posts you received.'] = 'عند تفعيله، لا نهاية لصلاحية مشاركاتك. ثم تكون الإعدادات أعلاه صالحة فقط للمشاركات التي استلمتها.';
$a->strings['Notification Settings'] = 'إعدادات التنبيهات';
$a->strings['Send a notification email when:'] = 'أرسل تنبيها للبريدي الإلكتروني عند:';
$a->strings['You receive an introduction'] = 'تلقي تقديم';
$a->strings['Your introductions are confirmed'] = 'أُكدت تقديماتك';
$a->strings['Someone writes on your profile wall'] = 'يكتب شخص ما على جدار ملفك الشخصي';
$a->strings['Someone writes a followup comment'] = 'شخص ما يعلق على ما نشرت';
$a->strings['You receive a private message'] = 'تلقي رسالة خاصة';
$a->strings['You receive a friend suggestion'] = 'تلقي اقتراح صداقة';
$a->strings['You are tagged in a post'] = 'ذُكرتَ في مشاركة';
$a->strings['Create a desktop notification when:'] = 'أنشئ تنبيه سطح المكتب عند:';
$a->strings['Someone liked your content'] = 'أُعجب شخص بمحتواك';
$a->strings['Someone shared your content'] = 'شارك شخص محتواك';
$a->strings['Activate desktop notifications'] = 'نشّط تنبيهات سطح المكتب';
$a->strings['Show desktop popup on new notifications'] = 'أظهر منبثقات للتنبيهات الجديدة';
$a->strings['Text-only notification emails'] = 'رسائل تنبيه نصية فقط';
$a->strings['Send text only notification emails, without the html part'] = 'أرسل بريد التنبيه كنص فقط، دون وسوم html';
$a->strings['Show detailled notifications'] = 'اعرض تنبيهات مفصلة';
$a->strings['Per default, notifications are condensed to a single notification per item. When enabled every notification is displayed.'] = 'افتراضيًا ، يعرض أحدث تنبيه فقط لكل محادثة. عند تفعيله ستعرض جميع التنبيهات.';
$a->strings['Show notifications of ignored contacts'] = 'أظهر تنبيهات للمتراسلين المتجاهلين';
$a->strings['You don\'t see posts from ignored contacts. But you still see their comments. This setting controls if you want to still receive regular notifications that are caused by ignored contacts or not.'] = 'أنت لا ترى مشاركات المتراسلين المتجاهلين. لكن لا يزال بإمكانك رؤية تعليقاتهم. هذا الإعداد يتحكم إذا كنت ترغب في الاستمرار في تلقي تنبيهات سببها المتراسلون المتجاهلون.';
$a->strings['Advanced Account/Page Type Settings'] = 'الإعدادات المتقدمة للحساب/للصفحة';
$a->strings['Change the behaviour of this account for special situations'] = 'غيّر سلوك هذا الحساب للحالات الخاصة';
$a->strings['Import Contacts'] = 'استيراد متراسلين';
$a->strings['Upload a CSV file that contains the handle of your followed accounts in the first column you exported from the old account.'] = 'ارفع ملف CSV معرفات المتراسلين لحسابك القديم، معرفات المتابَعين تكون في العمود الأول.';
$a->strings['Upload File'] = 'ارفع ملفًا';
$a->strings['Relocate'] = 'الانتقال';
$a->strings['If you have moved this profile from another server, and some of your contacts don\'t receive your updates, try pushing this button.'] = 'إذا كنت قد نقلت هذا الملف الشخصي من خادم آخر، وبعض المتراسلين لا يتلقون تحديثاتك، أنقر هذا الزر.';
$a->strings['Resend relocate message to contacts'] = 'أعد إرسال رسالة الانتقال للمتراسلين';
$a->strings['Delegation successfully granted.'] = 'منح التفويض بنجاح.'; $a->strings['Delegation successfully granted.'] = 'منح التفويض بنجاح.';
$a->strings['Parent user not found, unavailable or password doesn\'t match.'] = 'لم يُعثر على الولي أو هو غير متوفر أو كلمة مرور غير صحيحة.'; $a->strings['Parent user not found, unavailable or password doesn\'t match.'] = 'لم يُعثر على الولي أو هو غير متوفر أو كلمة مرور غير صحيحة.';
$a->strings['Delegation successfully revoked.'] = 'نجح إبطال التفويض.'; $a->strings['Delegation successfully revoked.'] = 'نجح إبطال التفويض.';
@ -2351,7 +2361,6 @@ $a->strings['Friendica respects your privacy. By default, your posts will only s
$a->strings['Getting Help'] = 'الحصول على مساعدة'; $a->strings['Getting Help'] = 'الحصول على مساعدة';
$a->strings['Go to the Help Section'] = 'انتقل إلى القسم المساعدة'; $a->strings['Go to the Help Section'] = 'انتقل إلى القسم المساعدة';
$a->strings['Our <strong>help</strong> pages may be consulted for detail on other program features and resources.'] = 'يمكنك الاطلاع على صفحات <strong>المساعدة</strong> للحصول على تفاصيل حول ميزات البرامج الأخرى ومصادرها.'; $a->strings['Our <strong>help</strong> pages may be consulted for detail on other program features and resources.'] = 'يمكنك الاطلاع على صفحات <strong>المساعدة</strong> للحصول على تفاصيل حول ميزات البرامج الأخرى ومصادرها.';
$a->strings['{0} wants to follow you'] = '{0} يريد متابعتك';
$a->strings['%s liked %s\'s post'] = 'أُعجب %s بمشاركة %s'; $a->strings['%s liked %s\'s post'] = 'أُعجب %s بمشاركة %s';
$a->strings['%s disliked %s\'s post'] = 'لم يُعجب %s بمشاركة %s'; $a->strings['%s disliked %s\'s post'] = 'لم يُعجب %s بمشاركة %s';
$a->strings['%s is attending %s\'s event'] = 'يحضر %s حدث %s'; $a->strings['%s is attending %s\'s event'] = 'يحضر %s حدث %s';
@ -2364,7 +2373,10 @@ $a->strings['Friend Suggestion'] = 'اقتراح صديق';
$a->strings['Friend/Connect Request'] = 'طلب صداقة/اقتران'; $a->strings['Friend/Connect Request'] = 'طلب صداقة/اقتران';
$a->strings['New Follower'] = 'متابِع جديد'; $a->strings['New Follower'] = 'متابِع جديد';
$a->strings['%1$s wants to follow you'] = '%1$s يريد متابعتك'; $a->strings['%1$s wants to follow you'] = '%1$s يريد متابعتك';
$a->strings['%1$s had started following you'] = '%1$s يتابعك';
$a->strings['%1$s liked your comment %2$s'] = 'أعجب %1$s بتعليقك %2$s';
$a->strings['%1$s liked your post %2$s'] = 'أعجب %1$s بمشاركتك %2$s'; $a->strings['%1$s liked your post %2$s'] = 'أعجب %1$s بمشاركتك %2$s';
$a->strings['%1$s disliked your comment %2$s'] = 'لم يعجب %1$s تعليقك %2$s';
$a->strings['%1$s disliked your post %2$s'] = 'لم يعجب %1$s مشاركتك %2$s'; $a->strings['%1$s disliked your post %2$s'] = 'لم يعجب %1$s مشاركتك %2$s';
$a->strings['%1$s shared your comment %2$s'] = 'شارك %1$s تعليقك %2$s'; $a->strings['%1$s shared your comment %2$s'] = 'شارك %1$s تعليقك %2$s';
$a->strings['%1$s shared your post %2$s'] = 'شارك %1$s مشاركتك %2$s'; $a->strings['%1$s shared your post %2$s'] = 'شارك %1$s مشاركتك %2$s';
@ -2440,6 +2452,7 @@ $a->strings['%s posted an update.'] = 'نشر %s تحديثاً.';
$a->strings['Private Message'] = 'رسالة خاصة'; $a->strings['Private Message'] = 'رسالة خاصة';
$a->strings['This entry was edited'] = 'عدّل المدخل'; $a->strings['This entry was edited'] = 'عدّل المدخل';
$a->strings['Edit'] = 'تعديل'; $a->strings['Edit'] = 'تعديل';
$a->strings['Pinned item'] = 'عنصر مثبت';
$a->strings['Delete globally'] = 'احذفه عالميًا'; $a->strings['Delete globally'] = 'احذفه عالميًا';
$a->strings['Remove locally'] = 'أزله محليًا'; $a->strings['Remove locally'] = 'أزله محليًا';
$a->strings['Block %s'] = 'احجب %s'; $a->strings['Block %s'] = 'احجب %s';

View file

@ -6604,7 +6604,7 @@ msgstr "Tester une adresse"
#: src/Module/BaseAdmin.php:115 #: src/Module/BaseAdmin.php:115
msgid "check webfinger" msgid "check webfinger"
msgstr "Vérifier le webfinger" msgstr "vérification de webfinger"
#: src/Module/BaseAdmin.php:117 #: src/Module/BaseAdmin.php:117
msgid "Babel" msgid "Babel"

View file

@ -1679,7 +1679,7 @@ $a->strings['Server Blocklist'] = 'Serveurs bloqués';
$a->strings['Diagnostics'] = 'Diagnostics'; $a->strings['Diagnostics'] = 'Diagnostics';
$a->strings['PHP Info'] = 'PHP Info'; $a->strings['PHP Info'] = 'PHP Info';
$a->strings['probe address'] = 'Tester une adresse'; $a->strings['probe address'] = 'Tester une adresse';
$a->strings['check webfinger'] = 'Vérifier le webfinger'; $a->strings['check webfinger'] = 'vérification de webfinger';
$a->strings['Babel'] = 'Babel'; $a->strings['Babel'] = 'Babel';
$a->strings['ActivityPub Conversion'] = 'Conversion ActivityPub'; $a->strings['ActivityPub Conversion'] = 'Conversion ActivityPub';
$a->strings['Addon Features'] = 'Fonctionnalités des addons'; $a->strings['Addon Features'] = 'Fonctionnalités des addons';

View file

@ -9071,7 +9071,7 @@ msgstr "Valaki kedvelte az Ön tartalmát"
#: src/Module/Settings/Account.php:622 src/Module/Settings/Account.php:623 #: src/Module/Settings/Account.php:622 src/Module/Settings/Account.php:623
msgid "Can only be enabled, when the direct comment notification is enabled." msgid "Can only be enabled, when the direct comment notification is enabled."
msgstr "Csak akkor engedélyezhető, ha a közvetlen hozzászólási értesítés engedélyezve van." msgstr ""
#: src/Module/Settings/Account.php:623 #: src/Module/Settings/Account.php:623
msgid "Someone shared your content" msgid "Someone shared your content"
@ -9079,7 +9079,7 @@ msgstr "Valaki megosztotta az Ön tartalmát"
#: src/Module/Settings/Account.php:624 #: src/Module/Settings/Account.php:624
msgid "Someone commented in your thread" msgid "Someone commented in your thread"
msgstr "Valaki hozzászólt az Ön szálában" msgstr ""
#: src/Module/Settings/Account.php:625 #: src/Module/Settings/Account.php:625
msgid "Someone commented in a thread where you commented" msgid "Someone commented in a thread where you commented"
@ -9087,7 +9087,7 @@ msgstr "Valaki hozzászólt egy olyan szálban, ahol Ön hozzászólt"
#: src/Module/Settings/Account.php:626 #: src/Module/Settings/Account.php:626
msgid "Someone commented in a thread where you interacted" msgid "Someone commented in a thread where you interacted"
msgstr "Valaki hozzászólt egy olyan szálban, ahol Ön interakcióba került" msgstr ""
#: src/Module/Settings/Account.php:628 #: src/Module/Settings/Account.php:628
msgid "Activate desktop notifications" msgid "Activate desktop notifications"

View file

@ -2263,11 +2263,8 @@ $a->strings['Create a desktop notification when:'] = 'Asztali értesítés létr
$a->strings['Someone tagged you'] = 'Valaki megjelölte Önt'; $a->strings['Someone tagged you'] = 'Valaki megjelölte Önt';
$a->strings['Someone directly commented on your post'] = 'Valaki közvetlenül hozzászólt a bejegyzéséhez'; $a->strings['Someone directly commented on your post'] = 'Valaki közvetlenül hozzászólt a bejegyzéséhez';
$a->strings['Someone liked your content'] = 'Valaki kedvelte az Ön tartalmát'; $a->strings['Someone liked your content'] = 'Valaki kedvelte az Ön tartalmát';
$a->strings['Can only be enabled, when the direct comment notification is enabled.'] = 'Csak akkor engedélyezhető, ha a közvetlen hozzászólási értesítés engedélyezve van.';
$a->strings['Someone shared your content'] = 'Valaki megosztotta az Ön tartalmát'; $a->strings['Someone shared your content'] = 'Valaki megosztotta az Ön tartalmát';
$a->strings['Someone commented in your thread'] = 'Valaki hozzászólt az Ön szálában';
$a->strings['Someone commented in a thread where you commented'] = 'Valaki hozzászólt egy olyan szálban, ahol Ön hozzászólt'; $a->strings['Someone commented in a thread where you commented'] = 'Valaki hozzászólt egy olyan szálban, ahol Ön hozzászólt';
$a->strings['Someone commented in a thread where you interacted'] = 'Valaki hozzászólt egy olyan szálban, ahol Ön interakcióba került';
$a->strings['Activate desktop notifications'] = 'Asztali értesítések bekapcsolása'; $a->strings['Activate desktop notifications'] = 'Asztali értesítések bekapcsolása';
$a->strings['Show desktop popup on new notifications'] = 'Felugró üzenet megjelenítése az asztalon új értesítések esetén.'; $a->strings['Show desktop popup on new notifications'] = 'Felugró üzenet megjelenítése az asztalon új értesítések esetén.';
$a->strings['Text-only notification emails'] = 'Csak szöveges értesítési e-mailek'; $a->strings['Text-only notification emails'] = 'Csak szöveges értesítési e-mailek';

View file

Some files were not shown because too many files have changed in this diff Show more