]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
this is going to take some more debug before it can be roller out
[friendica.git] / include / conversation.php
index 1b869b91e4a694354e48805268b9ac402b42bebb..d830c8daa6add5e3b6502b5ad9f05f519684b1b6 100644 (file)
@@ -173,6 +173,13 @@ function localize_item(&$item){
                                $item['body'] = str_replace($mtch[0],'@[url=' . zrl($mtch[1]). ']',$item['body']);
                }
        }
+       // add zrl's to public images
+       if(preg_match_all('/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is',$item['body'],$matches,PREG_SET_ORDER)) {
+               foreach($matches as $mtch) {
+                               $item['body'] = str_replace($mtch[0],'[url=' . zrl($mtch[1] . '/photos/' . $mtch[2] . '/image/' . $mtch[3] ,true) . '][img' . $mtch[4] . ']h' . $mtch[5]  . '[/img][/url]',$item['body']);
+               }
+       }
+
 
 }
 
@@ -278,6 +285,9 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                else
                                        $nickname = $a->user['nickname'];
                                
+                               // prevent private email from leaking.
+                               if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+                                               continue;
                        
                                $profile_name   = ((strlen($item['author-name']))   ? $item['author-name']   : $item['name']);
                                if($item['author-link'] && (! $item['author-name']))
@@ -298,7 +308,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                if(($normalised != 'mailbox') && (x($a->contacts[$normalised])))
                                        $profile_avatar = $a->contacts[$normalised]['thumb'];
                                else
-                                       $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
+                                       $profile_avatar = ((strlen($item['author-avatar'])) ? $a->get_cached_avatar_image($item['author-avatar']) : $item['thumb']);
 
                                $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
                                call_hooks('render_location',$locate);
@@ -447,8 +457,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                else {
 
                                        // prevent private email reply to public conversation from leaking.
-                                       if($item['private'] && ! $threads[$threadsid]['private'])
-                                               continue;
+                                       if($item['network'] === NETWORK_MAIL && local_user() != $item['uid'])
+                                                       continue;
 
                                        $comments_seen ++;
                                        $comment_lastcollapsed  = false;
@@ -492,7 +502,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
 
                                                // On the network page, I am the owner. On the display page it will be the profile owner.
                                                // This will have been stored in $a->page_contact by our calling page.
-                                               // Put this person on the left of the wall-to-wall notice.
+                                               // Put this person as the wall owner of the wall-to-wall notice.
 
                                                $owner_url = zrl($a->page_contact['url']);
                                                $owner_photo = $a->page_contact['thumb'];
@@ -500,37 +510,52 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                                $template = $wallwall;
                                                $commentww = 'ww';      
                                        }
-                                       if((! $item['wall']) && (strlen($item['owner-link'])) && (! link_compare($item['owner-link'],$item['author-link']))) {
 
-                                               // Could be anybody. 
-
-                                               $owner_url = $item['owner-link'];
-                                               $owner_photo = $item['owner-avatar'];
-                                               $owner_name = $item['owner-name'];
-                                               $template = $wallwall;
-                                               $commentww = 'ww';
-                                               // If it is our contact, use a friendly redirect link
-                                               if((link_compare($item['owner-link'],$item['url'])) 
-                                                       && ($item['network'] === NETWORK_DFRN)) {
-                                                       $owner_url = $redirect_url;
-                                                       $osparkle = ' sparkle';
+                                       if((! $item['wall']) && $item['owner-link']) {
+
+                                               $owner_linkmatch = (($item['owner-link']) && link_compare($item['owner-link'],$item['author-link']));
+                                               $alias_linkmatch = (($item['alias']) && link_compare($item['alias'],$item['author-link']));
+                                               $owner_namematch = (($item['owner-name']) && $item['owner-name'] == $item['author-name']);
+                                               if((! $owner_linkmatch) && (! $alias_linkmatch) && (! $owner_namematch)) {
+
+                                                       // The author url doesn't match the owner (typically the contact)
+                                                       // and also doesn't match the contact alias. 
+                                                       // The name match is a hack to catch several weird cases where URLs are 
+                                                       // all over the park. It can be tricked, but this prevents you from
+                                                       // seeing "Bob Smith to Bob Smith via Wall-to-wall" and you know darn
+                                                       // well that it's the same Bob Smith. 
+
+                                                       // But it could be somebody else with the same name. It just isn't highly likely. 
+                                                       
+
+                                                       $owner_url = $item['owner-link'];
+                                                       $owner_photo = $item['owner-avatar'];
+                                                       $owner_name = $item['owner-name'];
+                                                       $template = $wallwall;
+                                                       $commentww = 'ww';
+                                                       // If it is our contact, use a friendly redirect link
+                                                       if((link_compare($item['owner-link'],$item['url'])) 
+                                                               && ($item['network'] === NETWORK_DFRN)) {
+                                                               $owner_url = $redirect_url;
+                                                               $osparkle = ' sparkle';
+                                                       }
+                                                       else
+                                                               $owner_url = zrl($owner_url);
                                                }
-                                               else
-                                                       $owner_url = zrl($owner_url);
                                        }
                                }
 
                                $likebuttons = '';
-                               $shareable = ((($profile_owner == local_user()) &&  (! $item['private'])) ? true : false); //($mode != 'display') &&
+                               $shareable = ((($profile_owner == local_user()) &&  ((! $item['private']) || $item['network'] === NETWORK_FEED)) ? true : false); 
 
                                if($page_writeable) {
-                                       if($toplevelpost) {
+                                       if($toplevelpost) { 
                                                $likebuttons = array(
                                                        'like' => array( t("I like this \x28toggle\x29"), t("like")),
                                                        'dislike' => array( t("I don't like this \x28toggle\x29"), t("dislike")),
                                                );
                                                if ($shareable) $likebuttons['share'] = array( t('Share this'), t('share'));
-                                       }
+                                       } 
 
                                        $qc = $qcomment =  null;
 
@@ -553,6 +578,14 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                                        '$myphoto' => $a->contact['thumb'],
                                                        '$comment' => t('Comment'),
                                                        '$submit' => t('Submit'),
+                                                       '$edbold' => t('Bold'),
+                                                       '$editalic' => t('Italic'),
+                                                       '$eduline' => t('Underline'),
+                                                       '$edquote' => t('Quote'),
+                                                       '$edcode' => t('Code'),
+                                                       '$edimg' => t('Image'),
+                                                       '$edurl' => t('Link'),
+                                                       '$edvideo' => t('Video'),
                                                        '$preview' => t('Preview'),
                                                        '$ww' => (($mode === 'network') ? $commentww : '')
                                                ));
@@ -624,10 +657,10 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
                                        $profile_avatar = $a->contacts[$normalised]['thumb'];
                                else
-                                       $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb);
+                                       $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $a->get_cached_avatar_image($thumb));
 
-                               $like    = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
-                               $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
+                               $like    = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
+                               $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');
 
                                $locate = array('location' => $item['location'], 'coord' => $item['coord'], 'html' => '');
                                call_hooks('render_location',$locate);
@@ -843,13 +876,17 @@ function like_puller($a,$item,&$arr,$mode) {
                }
                else
                        $url = zrl($url);
-               if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l']))))
-                       $arr[$item['parent'] . '-l'] = array();
-               if(! isset($arr[$item['parent']]))
-                       $arr[$item['parent']] = 1;
+
+               if(! $item['thr-parent'])
+                       $item['thr-parent'] = $item['parent-uri'];
+
+               if(! ((isset($arr[$item['thr-parent'] . '-l'])) && (is_array($arr[$item['thr-parent'] . '-l']))))
+                       $arr[$item['thr-parent'] . '-l'] = array();
+               if(! isset($arr[$item['thr-parent']]))
+                       $arr[$item['thr-parent']] = 1;
                else    
-                       $arr[$item['parent']] ++;
-               $arr[$item['parent'] . '-l'][] = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>';
+                       $arr[$item['thr-parent']] ++;
+               $arr[$item['thr-parent'] . '-l'][] = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>';
        }
        return;
 }}
@@ -951,7 +988,7 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
        $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));        
 
        $o .= replace_macros($tpl,array(
-               '$return_path' => $a->cmd,
+               '$return_path' => $a->query_string,
                '$action' =>  $a->get_baseurl(true) . '/item',
                '$share' => (x($x,'button') ? $x['button'] : t('Share')),
                '$upload' => t('Upload photo'),