]> git.mxchange.org Git - friendica.git/blobdiff - mod/message.php
sn subscription fix
[friendica.git] / mod / message.php
index 83bad29d43647fea02fe1107e175a71dff5b59b4..7ca3fba70af9e939b744ca45b9cdec7797162a22 100644 (file)
@@ -46,7 +46,11 @@ function message_post(&$a) {
 
        // Work around doubled linefeeds in Tinymce 3.5b2
 
-       $plaintext = intval(get_pconfig(local_user(),'system','plaintext'));
+/*     $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);
        }
@@ -229,9 +233,12 @@ function message_content(&$a) {
                
                $o .= $header;
                
-               $plaintext = false;
+/*             $plaintext = false;
                if(intval(get_pconfig(local_user(),'system','plaintext')))
-                       $plaintext = true;
+                       $plaintext = true;*/
+               $plaintext = true;
+               if( local_user() && feature_enabled(local_user(),'richtext') )
+                       $plaintext = false;
 
 
                $tpl = get_markup_template('msg-header.tpl');
@@ -275,23 +282,25 @@ function message_content(&$a) {
 
                $tpl = get_markup_template('prv_message.tpl');
                $o .= replace_macros($tpl,array(
-                       '$header' => t('Send Private Message'),
-                       '$to' => t('To:'),
-                       '$showinputs' => 'true', 
-                       '$prefill' => $prefill,
-                       '$autocomp' => $autocomp,
-                       '$preid' => $preid,
-                       '$subject' => t('Subject:'),
-                       '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
-                       '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
-                       '$readonly' => '',
-                       '$yourmessage' => t('Your message:'),
-                       '$select' => $select,
-                       '$parent' => '',
-                       '$upload' => t('Upload photo'),
-                       '$insert' => t('Insert web link'),
-                       '$wait' => t('Please wait'),
-                       '$submit' => t('Submit')
+                       '$reply' => array(
+                               'header' => t('Send Private Message'),
+                               'to' => t('To:'),
+                               'showinputs' => 'true', 
+                               'prefill' => $prefill,
+                               'autocomp' => $autocomp,
+                               'preid' => $preid,
+                               'subject' => t('Subject:'),
+                               'subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
+                               'text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
+                               'readonly' => '',
+                               'yourmessage' => t('Your message:'),
+                               'select' => $select,
+                               'parent' => '',
+                               'upload' => t('Upload photo'),
+                               'insert' => t('Insert web link'),
+                               'wait' => t('Please wait'),
+                               'submit' => t('Submit')
+                       )
                ));
 
                return $o;
@@ -339,6 +348,17 @@ function message_content(&$a) {
                        else {
                                $partecipants = sprintf( t("%s and You"), $rr['from-name']);
                        }
+
+                       if($a->theme['template_engine'] === 'internal') {
+                               $subject_e = template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>'));
+                               $body_e = template_escape($rr['body']);
+                               $to_name_e = template_escape($rr['name']);
+                       }
+                       else {
+                               $subject_e = (($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>');
+                               $body_e = $rr['body'];
+                               $to_name_e = $rr['name'];
+                       }
                        
                        $o .= replace_macros($tpl, array(
                                '$id' => $rr['id'],
@@ -346,11 +366,12 @@ function message_content(&$a) {
                                '$from_url' => (($rr['network'] === NETWORK_DFRN) ? $a->get_baseurl(true) . '/redir/' . $rr['contact-id'] : $rr['url']),
                                '$sparkle' => ' sparkle',
                                '$from_photo' => (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']),
-                               '$subject' => template_escape((($rr['mailseen']) ? $rr['title'] : '<strong>' . $rr['title'] . '</strong>')),
+                               '$subject' => $subject_e,
                                '$delete' => t('Delete conversation'),
-                               '$body' => template_escape($rr['body']),
-                               '$to_name' => template_escape($rr['name']),
+                               '$body' => $body_e,
+                               '$to_name' => $to_name_e,
                                '$date' => datetime_convert('UTC',date_default_timezone_get(),$rr['mailcreated'], t('D, d M Y - g:i A')),
+                                '$ago' => relative_date($rr['mailcreated']),
                                '$seen' => $rr['mailseen'],
                                '$count' => sprintf( tt('%d message', '%d messages', $rr['count']), $rr['count']),
                        ));
@@ -363,6 +384,10 @@ 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",
@@ -400,14 +425,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)/'),
                        '$nickname' => $a->user['nickname'],
-                       '$baseurl' => $a->get_baseurl(true)
+                       '$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)/'),
                        '$nickname' => $a->user['nickname'],
-                       '$baseurl' => $a->get_baseurl(true)
+                       '$linkurl' => t('Please enter a link URL:')
                ));
 
 
@@ -432,17 +461,31 @@ function message_content(&$a) {
                        if($extracted['images'])
                                $message['body'] = item_redir_and_replace_images($extracted['body'], $extracted['images'], $message['contact-id']);
 
+                       if($a->theme['template_engine'] === 'internal') {
+                               $from_name_e = template_escape($message['from-name']);
+                               $subject_e = template_escape($message['title']);
+                               $body_e = template_escape(smilies(bbcode($message['body'])));
+                               $to_name_e = template_escape($message['name']);
+                       }
+                       else {
+                               $from_name_e = $message['from-name'];
+                               $subject_e = $message['title'];
+                               $body_e = smilies(bbcode($message['body']));
+                               $to_name_e = $message['name'];
+                       }
+
                        $mails[] = array(
                                'id' => $message['id'],
-                               'from_name' => template_escape($message['from-name']),
+                               'from_name' => $from_name_e,
                                'from_url' => $from_url,
                                'sparkle' => $sparkle,
                                'from_photo' => $message['from-photo'],
-                               'subject' => template_escape($message['title']),
-                               'body' => template_escape(smilies(bbcode($message['body']))),
+                               'subject' => $subject_e,
+                               'body' => $body_e,
                                'delete' => t('Delete message'),
-                               'to_name' => template_escape($message['name']),
+                               'to_name' => $to_name_e,
                                'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A'),
+                                'ago' => relative_date($message['created']),
                        );
                                
                        $seen = $message['seen'];
@@ -453,7 +496,21 @@ function message_content(&$a) {
                $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />';
 
                $tpl = get_markup_template('mail_display.tpl');
-               $o = replace_macros($tpl, array(
+
+               $includes = array(
+                       '$mail_conv' => 'mail_conv.tpl',
+                       '$prv_message' => 'prv_message.tpl',
+               );
+               $includes = set_template_includes($a->theme['template_engine'], $includes);
+
+               if($a->theme['template_engine'] === 'internal') {
+                       $subjtxt_e = template_escape($message['title']);
+               }
+               else {
+                       $subjtxt_e = $message['title'];
+               }
+
+               $o = replace_macros($tpl, $includes + array(
                        '$thread_id' => $a->argv[1],
                        '$thread_subject' => $message['title'],
                        '$thread_seen' => $seen,
@@ -463,20 +520,22 @@ function message_content(&$a) {
                        '$mails' => $mails,
                        
                        // reply
-                       '$header' => t('Send Reply'),
-                       '$to' => t('To:'),
-                       '$showinputs' => '',
-                       '$subject' => t('Subject:'),
-                       '$subjtxt' => template_escape($message['title']),
-                       '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
-                       '$yourmessage' => t('Your message:'),
-                       '$text' => '',
-                       '$select' => $select,
-                       '$parent' => $parent,
-                       '$upload' => t('Upload photo'),
-                       '$insert' => t('Insert web link'),
-                       '$submit' => t('Submit'),
-                       '$wait' => t('Please wait')
+                       '$reply_info' => array(
+                               'header' => t('Send Reply'),
+                               'to' => t('To:'),
+                               'showinputs' => '',
+                               'subject' => t('Subject:'),
+                               'subjtxt' => $subjtxt_e,
+                               'readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
+                               'yourmessage' => t('Your message:'),
+                               'text' => '',
+                               'select' => $select,
+                               'parent' => $parent,
+                               'upload' => t('Upload photo'),
+                               'insert' => t('Insert web link'),
+                               'submit' => t('Submit'),
+                               'wait' => t('Please wait'),
+                       ),
 
                ));