]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Merge pull request #67 from tomtom84/master
[friendica.git] / mod / item.php
index 99c01c54fd6c160e0e2fd85f96db82e0e1195541..81d7c753b42484e1fe787b3829803a9159d2449d 100755 (executable)
@@ -17,6 +17,7 @@
 
 require_once('include/crypto.php');
 require_once('include/enotify.php');
+require_once('include/email.php');
 
 function item_post(&$a) {
 
@@ -399,6 +400,8 @@ function item_post(&$a) {
 
        $body = preg_replace('/\[\/code\]\s*\[code\]/ism',"\n",$body); 
 
+       $body = scale_external_images($body,false);
+
        /**
         * Look for any tags and linkify them
         */
@@ -633,9 +636,24 @@ function item_post(&$a) {
 
        call_hooks('post_local',$datarray);
 
+       if(x($datarray,'cancel')) {
+               logger('mod_item: post cancelled by plugin.');
+               if($return_path) {
+                       goaway($a->get_baseurl() . "/" . $return_path);
+               }
+
+               $json = array('cancel' => 1);
+               if(x($_REQUEST,'jsreload') && strlen($_REQUEST['jsreload']))
+                       $json['reload'] = $a->get_baseurl() . '/' . $_REQUEST['jsreload'];
+
+               echo json_encode($json);
+               killme();
+       }
+
 
        if($orig_post) {
-               $r = q("UPDATE `item` SET `body` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
+               $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
+                       dbesc($title),
                        dbesc($body),
                        dbesc(datetime_convert()),
                        intval($post_id),
@@ -730,13 +748,15 @@ function item_post(&$a) {
                                        'language'     => $user['language'],
                                        'to_name'      => $user['username'],
                                        'to_email'     => $user['email'],
+                                       'uid'          => $user['uid'],
                                        'item'         => $datarray,
                                        'link'             => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
                                        'source_name'  => $datarray['author-name'],
                                        'source_link'  => $datarray['author-link'],
                                        'source_photo' => $datarray['author-avatar'],
                                        'verb'         => ACTIVITY_POST,
-                                       'otype'        => 'item'
+                                       'otype'        => 'item',
+                                       'parent'       => $parent,
                                ));
                        
                        }
@@ -772,6 +792,7 @@ function item_post(&$a) {
                                        'language'     => $user['language'],
                                        'to_name'      => $user['username'],
                                        'to_email'     => $user['email'],
+                                       'uid'          => $user['uid'],
                                        'item'         => $datarray,
                                        'link'             => $a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id,
                                        'source_name'  => $datarray['author-name'],
@@ -839,8 +860,8 @@ function item_post(&$a) {
                                $disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
                                $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL; 
 
-                               $subject  = '[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']);
-                               $headers  = 'From: ' . $a->user['username'] . ' <' . $a->user['email'] . '>' . "\n";
+                               $subject  = email_header_encode('[Friendica]' . ' ' . sprintf( t('%s posted an update.'),$a->user['username']),'UTF-8');
+                               $headers  = 'From: ' . email_header_encode($a->user['username'],'UTF-8') . ' <' . $a->user['email'] . '>' . "\n";
                                $headers .= 'MIME-Version: 1.0' . "\n";
                                $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n";
                                $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n";