<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2022, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
function message_post(App $a)
{
if (!local_user()) {
- notice(DI::l10n()->t('Permission denied.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return;
}
- $replyto = !empty($_REQUEST['replyto']) ? Strings::escapeTags(trim($_REQUEST['replyto'])) : '';
- $subject = !empty($_REQUEST['subject']) ? Strings::escapeTags(trim($_REQUEST['subject'])) : '';
- $body = !empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : '';
- $recipient = !empty($_REQUEST['recipient']) ? intval($_REQUEST['recipient']) : 0;
+ $replyto = !empty($_REQUEST['replyto']) ? trim($_REQUEST['replyto']) : '';
+ $subject = !empty($_REQUEST['subject']) ? trim($_REQUEST['subject']) : '';
+ $body = !empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : '';
+ $recipient = !empty($_REQUEST['recipient']) ? intval($_REQUEST['recipient']) : 0;
$ret = Mail::send($recipient, $body, $subject, $replyto);
$norecip = false;
switch ($ret) {
case -1:
- notice(DI::l10n()->t('No recipient selected.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('No recipient selected.'));
$norecip = true;
break;
case -2:
- notice(DI::l10n()->t('Unable to locate contact information.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate contact information.'));
break;
case -3:
- notice(DI::l10n()->t('Message could not be sent.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Message could not be sent.'));
break;
case -4:
- notice(DI::l10n()->t('Message collection failure.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Message collection failure.'));
break;
}
Nav::setSelected('messages');
if (!local_user()) {
- notice(DI::l10n()->t('Permission denied.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
if ($cmd === 'drop') {
$message = DBA::selectFirst('mail', ['convid'], ['id' => DI::args()->getArgv()[2], 'uid' => local_user()]);
if(!DBA::isResult($message)){
- notice(DI::l10n()->t('Conversation not found.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Conversation not found.'));
DI::baseUrl()->redirect('message');
}
if (!DBA::delete('mail', ['id' => DI::args()->getArgv()[2], 'uid' => local_user()])) {
- notice(DI::l10n()->t('Message was not deleted.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Message was not deleted.'));
}
$conversation = DBA::selectFirst('mail', ['id'], ['convid' => $message['convid'], 'uid' => local_user()]);
$parent = $parentmail['parent-uri'];
if (!DBA::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) {
- notice(DI::l10n()->t('Conversation was not removed.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Conversation was not removed.'));
}
}
DI::baseUrl()->redirect('message');
$o .= $header;
- $total = 0;
- $r = DBA::fetchFirst("SELECT count(*) AS `total`, ANY_VALUE(`created`) AS `created` FROM `mail`
- WHERE `mail`.`uid` = ? GROUP BY `parent-uri` ORDER BY `created` DESC",
- local_user()
- );
- if (DBA::isResult($r)) {
- $total = $r['total'];
- }
+ $total = DBA::count('mail', ['uid' => local_user()], ['distinct' => true, 'expression' => 'parent-uri']);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage());
if (!DBA::isResult($r)) {
- notice(DI::l10n()->t('No messages.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('No messages.'));
return $o;
}
}
if (!DBA::isResult($messages)) {
- notice(DI::l10n()->t('Message not available.'));
+ DI::sysmsg()->addNotice(DI::l10n()->t('Message not available.'));
return $o;
}
$body_e = BBCode::convertForUriId($message['uri-id'], $message['body']);
$to_name_e = $message['name'];
- $contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr', 'id', 'avatar']);
+ $contact = Contact::getByURL($message['from-url'], false, ['thumb', 'addr', 'id', 'avatar', 'url']);
$from_photo = Contact::getThumb($contact);
$mails[] = [
continue;
}
- $contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr', 'id', 'avatar']);
+ $contact = Contact::getByURL($rr['url'], false, ['thumb', 'addr', 'id', 'avatar', 'url']);
$from_photo = Contact::getThumb($contact);
$rslt .= Renderer::replaceMacros($tpl, [