X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fmessage.php;h=beaa7b1df666af66b426d01f821f0b790f7765d8;hb=3592f909105d09ac7d4d7bfebe47f4b3921763d6;hp=9bd5b0d72278bf0367cf79f4c3c7c59454924c17;hpb=c1193c9c134fb91e2ddbc2bf7b79f6ec1abb2e94;p=friendica.git diff --git a/mod/message.php b/mod/message.php index 9bd5b0d722..beaa7b1df6 100644 --- a/mod/message.php +++ b/mod/message.php @@ -4,7 +4,7 @@ require_once('include/acl_selectors.php'); require_once('include/message.php'); require_once('include/Smilies.php'); -function message_init(&$a) { +function message_init(App $a) { $tabs = ''; @@ -24,25 +24,25 @@ function message_init(&$a) { '$tabs'=>$tabs, '$new'=>$new, )); - $base = $a->get_baseurl(); + $base = App::get_baseurl(); $head_tpl = get_markup_template('message-head.tpl'); $a->page['htmlhead'] .= replace_macros($head_tpl,array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$base' => $base )); $end_tpl = get_markup_template('message-end.tpl'); $a->page['end'] .= replace_macros($end_tpl,array( - '$baseurl' => $a->get_baseurl(true), + '$baseurl' => App::get_baseurl(true), '$base' => $base )); } -function message_post(&$a) { +function message_post(App $a) { - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } @@ -52,17 +52,6 @@ function message_post(&$a) { $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); $recipient = ((x($_REQUEST,'messageto')) ? intval($_REQUEST['messageto']) : 0 ); - // Work around doubled linefeeds in Tinymce 3.5b2 - -/* $plaintext = intval(get_pconfig(local_user(),'system','plaintext') && !feature_enabled(local_user(),'richtext')); - if(! $plaintext) { - $body = fix_mce_lf($body); - }*/ - $plaintext = intval(!feature_enabled(local_user(),'richtext')); - if(! $plaintext) { - $body = fix_mce_lf($body); - } - $ret = send_message($recipient, $body, $subject, $replyto); $norecip = false; @@ -160,7 +149,7 @@ function item_redir_and_replace_images($body, $images, $cid) { $newbody = $newbody . $origbody; $cnt = 0; - foreach($images as $image) { + foreach ($images as $image) { // We're depending on the property of 'foreach' (specified on the PHP website) that // it loops over the array starting from the first element and going sequentially // to the last element @@ -173,17 +162,17 @@ function item_redir_and_replace_images($body, $images, $cid) { -function message_content(&$a) { +function message_content(App $a) { $o = ''; nav_set_selected('messages'); - if(! local_user()) { + if (! local_user()) { notice( t('Permission denied.') . EOL); return; } - $myprofile = $a->get_baseurl().'/profile/' . $a->user['nickname']; + $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname']; $tpl = get_markup_template('mail_head.tpl'); $header = replace_macros($tpl, array( @@ -231,10 +220,10 @@ function message_content(&$a) { intval($a->argv[2]), intval(local_user()) ); - if($r) { + if ($r) { info( t('Message deleted.') . EOL ); } - //goaway($a->get_baseurl(true) . '/message' ); + //goaway(App::get_baseurl(true) . '/message' ); goaway($_SESSION['return_url']); } else { @@ -265,7 +254,7 @@ function message_content(&$a) { if($r) info( t('Conversation removed.') . EOL ); } - //goaway($a->get_baseurl(true) . '/message' ); + //goaway(App::get_baseurl(true) . '/message' ); goaway($_SESSION['return_url']); } @@ -275,26 +264,16 @@ function message_content(&$a) { $o .= $header; -/* $plaintext = false; - if(intval(get_pconfig(local_user(),'system','plaintext'))) - $plaintext = true;*/ - $plaintext = true; - if( local_user() && feature_enabled(local_user(),'richtext') ) - $plaintext = false; - - $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), + '$baseurl' => App::get_baseurl(true), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:') )); $tpl = get_markup_template('msg-end.tpl'); $a->page['end'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), + '$baseurl' => App::get_baseurl(true), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:') )); @@ -364,13 +343,13 @@ function message_content(&$a) { $_SESSION['return_url'] = $a->query_string; - if($a->argc == 1) { + if ($a->argc == 1) { // List messages $o .= $header; - $r = q("SELECT count(*) AS `total` FROM `mail` + $r = q("SELECT count(*) AS `total` FROM `mail`, ANY_VALUE(`created`) AS `created` WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC", intval(local_user()) ); @@ -381,7 +360,7 @@ function message_content(&$a) { $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']); - if(! dbm::is_result($r)) { + if (! dbm::is_result($r)) { info( t('No messages.') . EOL); return $o; } @@ -397,10 +376,6 @@ function message_content(&$a) { $o .= $header; - $plaintext = true; - if( local_user() && feature_enabled(local_user(),'richtext') ) - $plaintext = false; - $r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb` FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` WHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1", @@ -438,21 +413,18 @@ function message_content(&$a) { $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), + '$baseurl' => App::get_baseurl(true), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:') )); $tpl = get_markup_template('msg-end.tpl'); $a->page['end'] .= replace_macros($tpl, array( - '$baseurl' => $a->get_baseurl(true), - '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), + '$baseurl' => App::get_baseurl(true), '$nickname' => $a->user['nickname'], '$linkurl' => t('Please enter a link URL:') )); - $mails = array(); $seen = 0; $unknown = false; @@ -556,12 +528,20 @@ function message_content(&$a) { } function get_messages($user, $lstart, $lend) { - + //TODO: rewritte with a sub-query to get the first message of each private thread with certainty return q("SELECT max(`mail`.`created`) AS `mailcreated`, min(`mail`.`seen`) AS `mailseen`, - `mail`.* , `contact`.`name`, `contact`.`url`, `contact`.`thumb` , `contact`.`network`, - count( * ) as count + ANY_VALUE(`mail`.`id`) AS `id`, ANY_VALUE(`mail`.`uid`) AS `uid`, ANY_VALUE(`mail`.`guid`) AS `guid`, + ANY_VALUE(`mail`.`from-name`) AS `from-name`, ANY_VALUE(`mail`.`from-photo`) AS `from-photo`, + ANY_VALUE(`mail`.`from-url`) AS `from-url`, ANY_VALUE(`mail`.`contact-id`) AS `contact-id`, + ANY_VALUE(`mail`.`convid`) AS `convid`, ANY_VALUE(`mail`.`title`) AS `title`, ANY_VALUE(`mail`.`body`) AS `body`, + ANY_VALUE(`mail`.`seen`) AS `seen`, ANY_VALUE(`mail`.`reply`) AS `reply`, ANY_VALUE(`mail`.`replied`) AS `replied`, + ANY_VALUE(`mail`.`unknown`) AS `unknown`, ANY_VALUE(`mail`.`uri`) AS `uri`, + `mail`.`parent-uri`, + ANY_VALUE(`mail`.`created`) AS `created`, ANY_VALUE(`contact`.`name`) AS `name`, ANY_VALUE(`contact`.`url`) AS `url`, + ANY_VALUE(`contact`.`thumb`) AS `thumb`, ANY_VALUE(`contact`.`network`) AS `network`, + count( * ) as `count` FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id` - WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", + WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `mailcreated` DESC LIMIT %d , %d ", intval($user), intval($lstart), intval($lend) ); } @@ -573,7 +553,7 @@ function render_messages(array $msg, $t) { $tpl = get_markup_template($t); $rslt = ''; - $myprofile = $a->get_baseurl().'/profile/' . $a->user['nickname']; + $myprofile = App::get_baseurl().'/profile/' . $a->user['nickname']; foreach($msg as $rr) {