mirror of
https://github.com/friendica/friendica
synced 2025-04-22 19:10:12 +00:00
Merge remote-tracking branch 'upstream/develop' into channel-languages
This commit is contained in:
commit
31b88da9d5
23 changed files with 1735 additions and 1897 deletions
|
@ -1,165 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2024, the Friendica project
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Profile;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session\Capability\IHandleUserSessions;
|
||||
use Friendica\Database\Database;
|
||||
use Friendica\Model\Mail;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\Response;
|
||||
use Friendica\Navigation\SystemMessages;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Profiler;
|
||||
use Friendica\Util\Strings;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
/**
|
||||
* Unknown Mail module
|
||||
*/
|
||||
class UnkMail extends \Friendica\BaseModule
|
||||
{
|
||||
/** @var IHandleUserSessions */
|
||||
private $userSessions;
|
||||
|
||||
/** @var SystemMessages */
|
||||
private $systemMessages;
|
||||
|
||||
/** @var Database */
|
||||
private $database;
|
||||
|
||||
/** @var App\Page */
|
||||
private $page;
|
||||
|
||||
public function __construct(App\Page $page, Database $database, SystemMessages $systemMessages, IHandleUserSessions $userSessions, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
|
||||
{
|
||||
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
|
||||
|
||||
$this->userSessions = $userSessions;
|
||||
$this->systemMessages = $systemMessages;
|
||||
$this->database = $database;
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
protected function post(array $request = [])
|
||||
{
|
||||
$replyto = $this->userSessions->getMyUrl();
|
||||
if (!$replyto) {
|
||||
$this->systemMessages->addNotice($this->l10n->t('Permission denied.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$recipient = $this->parameters['nickname'];
|
||||
$subject = trim($request['subject'] ?? '');
|
||||
$body = Strings::escapeHtml(trim($request['body'] ?? ''));
|
||||
|
||||
if (!$body) {
|
||||
$this->systemMessages->addNotice($this->l10n->t('Empty message body.'));
|
||||
return;
|
||||
}
|
||||
|
||||
$user = User::getByNickname($recipient);
|
||||
if (empty($user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$user['unkmail']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$total = $this->database->count('mail', ["`uid` = ? AND `created` > ? AND `unknown`", $user['uid'], DateTimeFormat::utc('now - 1 day')]);
|
||||
if ($total > $user['cntunkmail']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ret = Mail::sendWall($user, $body, $subject, $replyto);
|
||||
|
||||
switch ($ret) {
|
||||
case -1:
|
||||
$this->systemMessages->addNotice($this->l10n->t('No recipient selected.'));
|
||||
break;
|
||||
case -2:
|
||||
$this->systemMessages->addNotice($this->l10n->t('Unable to check your home location.'));
|
||||
break;
|
||||
case -3:
|
||||
$this->systemMessages->addNotice($this->l10n->t('Message could not be sent.'));
|
||||
break;
|
||||
case -4:
|
||||
$this->systemMessages->addNotice($this->l10n->t('Message collection failure.'));
|
||||
break;
|
||||
}
|
||||
|
||||
$this->baseUrl->redirect('profile/' . $user['nickname']);
|
||||
}
|
||||
|
||||
protected function content(array $request = []): string
|
||||
{
|
||||
$returnUrl = 'profile/' . $this->parameters['nickname'];
|
||||
|
||||
if (!$this->userSessions->getMyUrl()) {
|
||||
$this->systemMessages->addNotice($this->l10n->t('Permission denied.'));
|
||||
$this->baseUrl->redirect($returnUrl);
|
||||
}
|
||||
|
||||
$user = User::getByNickname($this->parameters['nickname']);
|
||||
if (empty($user)) {
|
||||
$this->systemMessages->addNotice($this->l10n->t('Recipient not found.'));
|
||||
$this->baseUrl->redirect($returnUrl);
|
||||
}
|
||||
|
||||
if (!$user['unkmail']) {
|
||||
$this->systemMessages->addNotice($this->l10n->t('Permission denied.'));
|
||||
$this->baseUrl->redirect($returnUrl);
|
||||
}
|
||||
|
||||
$total = $this->database->count('mail', ["`uid` = ? AND `created` > ? AND `unknown`", $user['uid'], DateTimeFormat::utc('now - 1 day')]);
|
||||
if ($total > $user['cntunkmail']) {
|
||||
$this->systemMessages->addNotice($this->l10n->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
|
||||
$this->baseUrl->redirect($returnUrl);
|
||||
}
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/unkmail-header.tpl');
|
||||
$this->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
|
||||
'$nickname' => $user['nickname'],
|
||||
'$linkurl' => $this->l10n->t('Please enter a link URL:')
|
||||
]);
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/unkmail.tpl');
|
||||
return Renderer::replaceMacros($tpl, [
|
||||
'$l10n' => [
|
||||
'header' => $this->l10n->t('Send Private Message'),
|
||||
'subheader' => $this->l10n->t('If you wish for %s to respond, please check that the privacy settings on your site allow private mail from unknown senders.', $user['username']),
|
||||
'insert' => $this->l10n->t('Insert web link'),
|
||||
'wait' => $this->l10n->t('Please wait'),
|
||||
'submit' => $this->l10n->t('Submit'),
|
||||
],
|
||||
|
||||
'$nickname' => $user['nickname'],
|
||||
|
||||
'$to' => ['to' , $this->l10n->t('To') , $user['username'], '', '', 'disabled'],
|
||||
'$subject' => ['subject', $this->l10n->t('Subject') , $request['subject'] ?? ''],
|
||||
'$body' => ['body' , $this->l10n->t('Your message'), $request['body'] ?? ''],
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -160,8 +160,6 @@ class Account extends BaseSettings
|
|||
$hidewall = !empty($request['hidewall']);
|
||||
$blockwall = empty($request['blockwall']); // this setting is inverted!
|
||||
$blocktags = empty($request['blocktags']); // this setting is inverted!
|
||||
$unkmail = !empty($request['unkmail']);
|
||||
$cntunkmail = intval($request['cntunkmail'] ?? 0);
|
||||
$def_gid = intval($request['circle-selection'] ?? 0);
|
||||
|
||||
$aclFormatter = DI::aclFormatter();
|
||||
|
@ -185,8 +183,6 @@ class Account extends BaseSettings
|
|||
'blockwall' => $blockwall,
|
||||
'hidewall' => $hidewall,
|
||||
'blocktags' => $blocktags,
|
||||
'unkmail' => $unkmail,
|
||||
'cntunkmail' => $cntunkmail,
|
||||
];
|
||||
|
||||
$profile_fields = [
|
||||
|
@ -408,8 +404,6 @@ class Account extends BaseSettings
|
|||
$openid = $user['openid'];
|
||||
$maxreq = $user['maxreq'];
|
||||
$expire = $user['expire'] ?: '';
|
||||
$unkmail = $user['unkmail'];
|
||||
$cntunkmail = $user['cntunkmail'];
|
||||
|
||||
$expire_items = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'items', true);
|
||||
$expire_notes = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'expire', 'notes', true);
|
||||
|
@ -571,8 +565,6 @@ class Account extends BaseSettings
|
|||
'$accessiblephotos' => ['accessible-photos', DI::l10n()->t('Make all posted pictures accessible'), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'accessible-photos'), DI::l10n()->t("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.")],
|
||||
'$blockwall' => ['blockwall', DI::l10n()->t('Allow friends to post to your profile page?'), (intval($user['blockwall']) ? '0' : '1'), DI::l10n()->t('Your contacts may write posts on your profile wall. These posts will be distributed to your contacts')],
|
||||
'$blocktags' => ['blocktags', DI::l10n()->t('Allow friends to tag your posts?'), (intval($user['blocktags']) ? '0' : '1'), DI::l10n()->t('Your contacts can add additional tags to your posts.')],
|
||||
'$unkmail' => ['unkmail', DI::l10n()->t('Permit unknown people to send you private mail?'), $unkmail, DI::l10n()->t('Friendica network users may send you private messages even if they are not in your contact list.')],
|
||||
'$cntunkmail' => ['cntunkmail', DI::l10n()->t('Maximum private messages per day from unknown people:'), $cntunkmail, DI::l10n()->t("(to prevent spam abuse)")],
|
||||
'$circle_select' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), $user['def_gid'], 'circle-selection', DI::l10n()->t('Default privacy circle for new contacts')),
|
||||
'$circle_select_group' => Circle::getSelectorHTML(DI::userSession()->getLocalUserId(), DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'default-group-gid', $user['def_gid']), 'circle-selection-group', DI::l10n()->t('Default privacy circle for new group contacts')),
|
||||
'$permissions' => DI::l10n()->t('Default Post Permissions'),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue