Files
friendica/mod/message.php
Roland Häder 8ad523fbc8 Continued a bit:
- removed/fixed whitespaces and mixture of spaces/tabs (some)
- added new-line character at end of files (POSIX-compilant)
- reverted some code which I had messed up (compared to upstream/develop)
- removed duplicate dba::update() invocation in src/Protocol/DFRN.php
- also removed no longer valid TODO

Signed-off-by: Roland Häder <roland@mxchange.org>
2018-06-20 22:19:54 +02:00

489 lines
14 KiB
PHP

<?php
/**
* @file mod/message.php
*/
use Friendica\App;
use Friendica\Content\Nav;
use Friendica\Content\Smilies;
use Friendica\Content\Text\BBCode;
use Friendica\Core\ACL;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Mail;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
require_once 'include/conversation.php';
function message_init(App $a)
{
$tabs = '';
if ($a->argc > 1 && is_numeric($a->argv[1])) {
$tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl');
}
$new = [
'label' => L10n::t('New Message'),
'url' => 'message/new',
'sel' => $a->argc > 1 && $a->argv[1] == 'new',
'accesskey' => 'm',
];
$tpl = get_markup_template('message_side.tpl');
$a->page['aside'] = replace_macros($tpl, [
'$tabs' => $tabs,
'$new' => $new,
]);
$base = System::baseUrl();
$head_tpl = get_markup_template('message-head.tpl');
$a->page['htmlhead'] .= replace_macros($head_tpl, [
'$baseurl' => System::baseUrl(true),
'$base' => $base
]);
$end_tpl = get_markup_template('message-end.tpl');
$a->page['end'] .= replace_macros($end_tpl, [
'$baseurl' => System::baseUrl(true),
'$base' => $base
]);
}
function message_post(App $a)
{
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
return;
}
$replyto = x($_REQUEST, 'replyto') ? notags(trim($_REQUEST['replyto'])) : '';
$subject = x($_REQUEST, 'subject') ? notags(trim($_REQUEST['subject'])) : '';
$body = x($_REQUEST, 'body') ? escape_tags(trim($_REQUEST['body'])) : '';
$recipient = x($_REQUEST, 'messageto') ? intval($_REQUEST['messageto']) : 0;
$ret = Mail::send($recipient, $body, $subject, $replyto);
$norecip = false;
switch ($ret) {
case -1:
notice(L10n::t('No recipient selected.') . EOL);
$norecip = true;
break;
case -2:
notice(L10n::t('Unable to locate contact information.') . EOL);
break;
case -3:
notice(L10n::t('Message could not be sent.') . EOL);
break;
case -4:
notice(L10n::t('Message collection failure.') . EOL);
break;
default:
info(L10n::t('Message sent.') . EOL);
}
// fake it to go back to the input form if no recipient listed
if ($norecip) {
$a->argc = 2;
$a->argv[1] = 'new';
} else {
goaway($_SESSION['return_url']);
}
}
function message_content(App $a)
{
$o = '';
Nav::setSelected('messages');
if (!local_user()) {
notice(L10n::t('Permission denied.') . EOL);
return;
}
$myprofile = System::baseUrl() . '/profile/' . $a->user['nickname'];
$tpl = get_markup_template('mail_head.tpl');
$header = replace_macros($tpl, [
'$messages' => L10n::t('Messages'),
]);
if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) {
if (!intval($a->argv[2])) {
return;
}
// Check if we should do HTML-based delete confirmation
if ($_REQUEST['confirm']) {
// <form> can't take arguments in its "action" parameter
// so add any arguments as hidden inputs
$query = explode_querystring($a->query_string);
$inputs = [];
foreach ($query['args'] as $arg) {
if (strpos($arg, 'confirm=') === false) {
$arg_parts = explode('=', $arg);
$inputs[] = ['name' => $arg_parts[0], 'value' => $arg_parts[1]];
}
}
//$a->page['aside'] = '';
return replace_macros(get_markup_template('confirm.tpl'), [
'$method' => 'get',
'$message' => L10n::t('Do you really want to delete this message?'),
'$extra_inputs' => $inputs,
'$confirm' => L10n::t('Yes'),