]> git.mxchange.org Git - friendica.git/blobdiff - mod/message.php
Replace "notice" calls
[friendica.git] / mod / message.php
index 7324840a0e3acb4d1183246dd673416f27e9a960..d1231b7c5dcb0425a91feb61f0511c6be30674e5 100644 (file)
@@ -1,6 +1,6 @@
 <?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
  *
@@ -66,31 +66,31 @@ function message_init(App $a)
 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;
        }
 
@@ -108,7 +108,7 @@ function message_content(App $a)
        Nav::setSelected('messages');
 
        if (!local_user()) {
-               notice(DI::l10n()->t('Permission denied.'));
+               DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.'));
                return Login::form();
        }
 
@@ -143,12 +143,12 @@ function message_content(App $a)
                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()]);
@@ -163,7 +163,7 @@ function message_content(App $a)
                                $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');
@@ -212,21 +212,14 @@ function message_content(App $a)
 
                $o .= $header;
 
-               $total = 0;
-               $r = q("SELECT count(*) AS `total`, ANY_VALUE(`created`) AS `created` FROM `mail`
-                       WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC",
-                       intval(local_user())
-               );
-               if (DBA::isResult($r)) {
-                       $total = $r[0]['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;
                }
 
@@ -282,7 +275,7 @@ function message_content(App $a)
                }
 
                if (!DBA::isResult($messages)) {
-                       notice(DI::l10n()->t('Message not available.'));
+                       DI::sysmsg()->addNotice(DI::l10n()->t('Message not available.'));
                        return $o;
                }
 
@@ -315,7 +308,7 @@ function message_content(App $a)
                        $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[] = [
@@ -447,7 +440,7 @@ function render_messages(array $msg, $t)
                        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, [