]> git.mxchange.org Git - friendica.git/blobdiff - mod/message.php
Merge pull request #5224 from rabuzarus/20180615_-_frio_frix_js_error_callAddonHooks
[friendica.git] / mod / message.php
index 40f1dd08c0d9cdc2d598e40c93f637dc198d103e..987babf74467b72b1111896d42e34198e9562ea9 100644 (file)
@@ -7,6 +7,7 @@ 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;
@@ -15,7 +16,6 @@ use Friendica\Model\Mail;
 use Friendica\Util\DateTimeFormat;
 use Friendica\Util\Temporal;
 
-require_once 'include/acl_selectors.php';
 require_once 'include/conversation.php';
 
 function message_init(App $a)
@@ -148,11 +148,7 @@ function message_content(App $a)
 
                $cmd = $a->argv[1];
                if ($cmd === 'drop') {
-                       $r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1",
-                               intval($a->argv[2]),
-                               intval(local_user())
-                       );
-                       if ($r) {
+                       if (dba::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) {
                                info(L10n::t('Message deleted.') . EOL);
                        }
                        //goaway(System::baseUrl(true) . '/message' );
@@ -166,22 +162,7 @@ function message_content(App $a)
                                $parent = $r[0]['parent-uri'];
                                $convid = $r[0]['convid'];
 
-                               $r = q("DELETE FROM `mail` WHERE `parent-uri` = '%s' AND `uid` = %d ",
-                                       dbesc($parent),
-                                       intval(local_user())
-                               );
-
-                               // remove diaspora conversation pointer
-                               // Actually if we do this, we can never receive another reply to that conversation,
-                               // as we will never again have the info we need to re-create it.
-                               // We'll just have to orphan it.
-                               //if ($convid) {
-                               //      q("delete from conv where id = %d limit 1",
-                               //              intval($convid)
-                               //      );
-                               //}
-
-                               if ($r) {
+                               if (dba::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) {
                                        info(L10n::t('Conversation removed.') . EOL);
                                }
                        }
@@ -207,7 +188,7 @@ function message_content(App $a)
                        '$linkurl' => L10n::t('Please enter a link URL:')
                ]);
 
-               $preselect = isset($a->argv[2]) ? [$a->argv[2]] : false;
+               $preselect = isset($a->argv[2]) ? [$a->argv[2]] : [];
 
                $prename = $preurl = $preid = '';
 
@@ -236,14 +217,14 @@ function message_content(App $a)
                                $preid = $r[0]['id'];
                                $preselect = [$preid];
                        } else {
-                               $preselect = false;
+                               $preselect = [];
                        }
                }
 
                $prefill = $preselect ? $prename : '';
 
                // the ugly select box
-               $select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10);
+               $select = ACL::getMessageContactSelectHTML('messageto', 'message-to-select', $preselect, 4, 10);
 
                $tpl = get_markup_template('prv_message.tpl');
                $o .= replace_macros($tpl, [
@@ -360,11 +341,8 @@ function message_content(App $a)
                        if ($message['from-url'] == $myprofile) {
                                $from_url = $myprofile;
                                $sparkle = '';
-                       } elseif ($message['contact-id'] != 0) {
-                               $from_url = 'redir/' . $message['contact-id'];
-                               $sparkle = ' sparkle';
                        } else {
-                               $from_url = $message['from-url'] . "?zrl=" . urlencode($myprofile);
+                               $from_url = Contact::magicLink($message['from-url']);
                                $sparkle = ' sparkle';
                        }
 
@@ -489,7 +467,7 @@ function render_messages(array $msg, $t)
                $rslt .= replace_macros($tpl, [
                        '$id' => $rr['id'],
                        '$from_name' => $participants,
-                       '$from_url' => (($rr['network'] === NETWORK_DFRN) ? 'redir/' . $rr['contact-id'] : $rr['url']),
+                       '$from_url' => Contact::magicLink($rr['url']),
                        '$from_addr' => $contact['addr'],
                        '$sparkle' => ' sparkle',
                        '$from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB),