]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Send notifications for each new post of a contact, option for creating a summary...
[friendica.git] / include / conversation.php
index cc66d380b7561463670beca0c3e8203a729b41f6..31f40aa6f8ca20767b47f90e94194719e091a8f5 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 require_once("include/bbcode.php");
+require_once("include/acl_selectors.php");
 
 
 // Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
@@ -368,7 +369,6 @@ function visible_activity($item) {
 if(!function_exists('conversation')) {
 function conversation(&$a, $items, $mode, $update, $preview = false) {
 
-
        require_once('include/bbcode.php');
 
        $ssl_state = ((local_user()) ? true : false);
@@ -377,6 +377,18 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
        $page_writeable = false;
        $live_update_div = '';
 
+       $arr_blocked = null;
+
+       if(local_user()) {
+               $str_blocked = get_pconfig(local_user(),'system','blocked');
+               if($str_blocked) {
+                       $arr_blocked = explode(',',$str_blocked);
+                       for($x = 0; $x < count($arr_blocked); $x ++)
+                               $arr_blocked[$x] = trim($arr_blocked[$x]);
+               }
+
+       }
+
        $previewing = (($preview) ? ' preview ' : '');
 
        if($mode === 'network') {
@@ -475,7 +487,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
        $alike = array();
        $dlike = array();
 
-
        // array with html for each thread (parent+comments)
        $threads = array();
        $threadsid = -1;
@@ -493,6 +504,19 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                        $tpl = 'search_item.tpl';
 
                        foreach($items as $item) {
+                               if($arr_blocked) {
+                                       $blocked = false;
+                                       foreach($arr_blocked as $b) {
+                                               if($b && link_compare($item['author-link'],$b)) {
+                                                       $blocked = true;
+                                                       break;
+                                               }
+                                       }
+                                       if($blocked)
+                                               continue;
+                               }
+
+
                                $threadsid++;
 
                                $comment     = '';
@@ -672,7 +696,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                $threads[$threadsid]['items'] = array($arr['output']);
 
                        }
-
                }
                else
                {
@@ -691,6 +714,21 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                        $threads = array();
                        foreach($items as $item) {
 
+                               if($arr_blocked) {
+                                       $blocked = false;
+                                       foreach($arr_blocked as $b) {
+
+                                               if($b && link_compare($item['author-link'],$b)) {
+                                                       $blocked = true;
+                                                       break;
+                                               }
+                                       }
+                                       if($blocked)
+                                               continue;
+                               }
+
+
+
                                // Can we put this after the visibility check?
                                like_puller($a,$item,$alike,'like');
                                like_puller($a,$item,$dlike,'dislike');
@@ -703,6 +741,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                                        continue;
                                }
 
+                               call_hooks('display_item', $arr);
+
                                $item['pagedrop'] = $page_dropping;
 
                                if($item['id'] == $item['parent']) {
@@ -712,6 +752,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
                        }
 
                        $threads = $conv->get_template_data($alike, $dlike);
+
                        if(!$threads) {
                                logger('[ERROR] conversation : Failed to get template data.', LOGGER_DEBUG);
                                $threads = array();
@@ -721,6 +762,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
 
        $o = replace_macros($page_template, array(
                '$baseurl' => $a->get_baseurl($ssl_state),
+               '$return_path' => $a->query_string,
                '$live_update' => $live_update_div,
                '$remove' => t('remove'),
                '$mode' => $mode,
@@ -810,7 +852,7 @@ function item_photo_menu($item){
        if(($cid) && (! $item['self'])) {
                $poke_link = $a->get_baseurl($ssl_state) . '/poke/?f=&c=' . $cid;
                $contact_url = $a->get_baseurl($ssl_state) . '/contacts/' . $cid;
-               $posts_link = $a->get_baseurl($ssl_state) . '/network/?cid=' . $cid;
+               $posts_link = $a->get_baseurl($ssl_state) . '/network/0?nets=all&cid=' . $cid;
 
                $clean_url = normalise_link($item['author-link']);
 
@@ -925,7 +967,7 @@ function format_like($cnt,$arr,$type,$id) {
                        $str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS );
                }
                $str = (($type === 'like') ? sprintf( t('%s like this.'), $str) : sprintf( t('%s don\'t like this.'), $str));
-               $o .= "\t" . '<div id="' . $type . 'list-' . $id . '" style="display: none;" >' . $str . '</div>';
+               $o .= "\t" . '<div class="wall-item-' . $type . '-expanded" id="' . $type . 'list-' . $id . '" style="display: none;" >' . $str . '</div>';
        }
        return $o;
 }}
@@ -979,8 +1021,6 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
        ));
 
 
-       $tpl = get_markup_template("jot.tpl");
-
        $jotplugins = '';
        $jotnets = '';
 
@@ -1011,10 +1051,31 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
        if($notes_cid)
                $jotnets .= '<input type="hidden" name="contact_allow[]" value="' . $notes_cid .'" />';
 
+
+       // Private/public post links for the non-JS ACL form
+       $private_post = 1;
+       if($_REQUEST['public'])
+               $private_post = 0;
+
+       $query_str = $a->query_string;
+       if(strpos($query_str, 'public=1') !== false)
+               $query_str = str_replace(array('?public=1', '&public=1'), array('', ''), $query_str);
+
+       // I think $a->query_string may never have ? in it, but I could be wrong
+       // It looks like it's from the index.php?q=[etc] rewrite that the web
+       // server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
+       if(strpos($query_str, '?') === false)
+               $public_post_link = '?public=1';
+       else
+               $public_post_link = '&public=1';
+
+
+
 //     $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins));
+       $tpl = get_markup_template("jot.tpl");
 
        $o .= replace_macros($tpl,array(
-               '$return_path' => $a->query_string,
+               '$return_path' => $query_str,
                '$action' =>  $a->get_baseurl(true) . '/item',
                '$share' => (x($x,'button') ? $x['button'] : t('Share')),
                '$upload' => t('Upload photo'),
@@ -1050,14 +1111,22 @@ function status_editor($a,$x, $notes_cid = 0, $popup=false) {
                '$jotnets' => $jotnets,
                '$emtitle' => t('Example: bob@example.com, mary@example.com'),
                '$lockstate' => $x['lockstate'],
-               '$acl' => $x['acl'],
                '$bang' => $x['bang'],
                '$profile_uid' => $x['profile_uid'],
                '$preview' => ((feature_enabled($x['profile_uid'],'preview')) ? t('Preview') : ''),
                '$jotplugins' => $jotplugins,
                '$sourceapp' => t($a->sourcename),
                '$cancel' => t('Cancel'),
-               '$rand_num' => random_digits(12)
+               '$rand_num' => random_digits(12),
+
+               // ACL permissions box
+               '$acl' => $x['acl'],
+               '$acl_data' => $x['acl_data'],
+               '$group_perms' => t('Post to Groups'),
+               '$contact_perms' => t('Post to Contacts'),
+               '$private' => t('Private post'),
+               '$is_private' => $private_post,
+               '$public_link' => $public_post_link,
        ));