]> git.mxchange.org Git - friendica.git/blobdiff - mod/item.php
Merge commit 'mike/master'
[friendica.git] / mod / item.php
index 737fe83419baa09fa6bb8f845bd3dc39a670af1d..8c6b181c0d557dfdbd4631e45fb09359d0375877 100644 (file)
@@ -22,6 +22,8 @@ function item_post(&$a) {
 
        $uid = local_user();
 
+       call_hooks('post_local_start', $_POST);
+
        $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0);
 
        $parent_item = null;
@@ -33,7 +35,9 @@ function item_post(&$a) {
                );
                if(! count($r)) {
                        notice( t('Unable to locate original post.') . EOL);
-                       goaway($a->get_baseurl() . "/" . $_POST['return'] );
+                       if(x($_POST,'return')) 
+                               goaway($a->get_baseurl() . "/" . $_POST['return'] );
+                       killme();
                }
                $parent_item = $r[0];
                if($parent_item['contact-id'] && $uid) {
@@ -51,7 +55,9 @@ function item_post(&$a) {
 
        if(! can_write_wall($a,$profile_uid)) {
                notice( t('Permission denied.') . EOL) ;
-               return;
+               if(x($_POST,'return')) 
+                       goaway($a->get_baseurl() . "/" . $_POST['return'] );
+               killme();
        }
 
        $user = null;
@@ -90,8 +96,9 @@ function item_post(&$a) {
 
        if(! strlen($body)) {
                notice( t('Empty post discarded.') . EOL );
-               goaway($a->get_baseurl() . "/" . $_POST['return'] );
-
+               if(x($_POST,'return')) 
+                       goaway($a->get_baseurl() . "/" . $_POST['return'] );
+               killme();
        }
 
        // get contact info for poster
@@ -427,10 +434,11 @@ function item_post(&$a) {
                        }
                }
 
-               $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `changed` = '%s', `last-child` = 1, `visible` = 1
+               $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `plink` = '%s', `changed` = '%s', `last-child` = 1, `visible` = 1
                        WHERE `id` = %d LIMIT 1",
                        intval($parent),
                        dbesc(($parent == $post_id) ? $uri : $parent_item['uri']),
+                       dbesc($a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id),
                        dbesc(datetime_convert()),
                        intval($post_id)
                );
@@ -488,7 +496,19 @@ function item_post(&$a) {
                }
        }
 
-       goaway($a->get_baseurl() . "/" . $_POST['return'] );
+       logger('post_complete');
+       if((x($_POST,'return')) && strlen($_POST['return'])) {
+               logger('return: ' . $_POST['return']);
+               goaway($a->get_baseurl() . "/" . $_POST['return'] );
+       }
+       $json = array('success' => 1);
+       if(x($_POST,'jsreload') && strlen($_POST['jsreload']))
+               $json['reload'] = $a->get_baseurl() . '/' . $_POST['jsreload'];
+
+       logger('post_json: ' . print_r($json,true), LOGGER_DEBUG);
+
+       echo json_encode($json);
+       killme();
        // NOTREACHED
 }
 
@@ -537,7 +557,7 @@ function item_content(&$a) {
                        // generate a resource-id and therefore aren't intimately linked to the item. 
 
                        if(strlen($item['resource-id'])) {
-                               $q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ",
+                               q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ",
                                        dbesc($item['resource-id']),
                                        intval($item['uid'])
                                );