From d7407f8daaab14ecba59cc3cb211ff93802dd761 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 27 Feb 2012 17:18:19 -0800 Subject: cleanup notify subject lines --- include/enotify.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index 67e0011b8..76e7eb9dc 100755 --- a/include/enotify.php +++ b/include/enotify.php @@ -27,7 +27,7 @@ function notification($params) { if($params['type'] == NOTIFY_MAIL) { - $subject = sprintf( t('New mail received at %s'),$sitename); + $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename); $preamble = sprintf( t('%s sent you a new private message at %s.'),$params['source_name'],$sitename); $epreamble = sprintf( t('%s sent you %s.'),'[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a private message') . '[/url]'); @@ -38,7 +38,7 @@ function notification($params) { } if($params['type'] == NOTIFY_COMMENT) { - logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); +// logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); $parent_id = $params['parent']; @@ -46,7 +46,8 @@ function notification($params) { // So, we cannot have different subjects for notifications of the same thread. // Before this we have the name of the replier on the subject rendering // differents subjects for messages on the same thread. - $subject = sprintf( t('Someone commented on item #%d at %s'), $parent_id, $sitename); + + $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%d by %s'), $parent_id, $params['source_name']); $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); $epreamble = sprintf( t('%s commented in %s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a watched conversation') . '[/url]'); @@ -57,7 +58,10 @@ function notification($params) { } if($params['type'] == NOTIFY_WALL) { - $preamble = $subject = sprintf( t('%s posted to your profile wall at %s') , $params['source_name'], $sitename); + $subject = sprintf( t('[Friendica:Notify] %s posted to your profile wall') , $params['source_name']); + + $preamble = sprintf( t('%s posted to your profile wall at %s') , $params['source_name'], $sitename); + $epreamble = sprintf( t('%s posted to %s') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('your profile wall.') . '[/url]'); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); @@ -67,7 +71,8 @@ function notification($params) { } if($params['type'] == NOTIFY_TAGSELF) { - $preamble = $subject = sprintf( t('%s tagged you at %s') , $params['source_name'], $sitename); + $subject = sprintf( t('[Friendica:Notify] %s tagged you') , $params['source_name']); + $preamble = sprintf( t('%s tagged you at %s') , $params['source_name'], $sitename); $epreamble = sprintf( t('%s %s.') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=' . $params['link'] . ']' . t('tagged you') . '[/url]'); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); @@ -77,7 +82,8 @@ function notification($params) { } if($params['type'] == NOTIFY_TAGSHARE) { - $preamble = $subject = sprintf( t('%s tagged your post at %s') , $params['source_name'], $sitename); + $subject = sprintf( t('[Friendica:Notify] %s tagged your post') , $params['source_name']); + $preamble = sprintf( t('%s tagged your post at %s') , $params['source_name'], $sitename); $epreamble = sprintf( t('%s tagged %s') , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('your post') . '[/url]' ); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); @@ -87,7 +93,7 @@ function notification($params) { } if($params['type'] == NOTIFY_INTRO) { - $subject = sprintf( t('Introduction received at %s'), $sitename); + $subject = sprintf( t('[Friendica:Notify] Introduction received')); $preamble = sprintf( t('You\'ve received an introduction from \'%s\' at %s'), $params['source_name'], $sitename); $epreamble = sprintf( t('You\'ve received %s from %s.'), '[url=$itemlink]' . t('an introduction') . '[/url]' , '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]'); $body = sprintf( t('You may visit their profile at %s'),$params['source_link']); @@ -99,7 +105,7 @@ function notification($params) { } if($params['type'] == NOTIFY_SUGGEST) { - $subject = sprintf( t('Friend suggestion received at %s'), $sitename); + $subject = sprintf( t('[Friendica:Notify] Friend suggestion received')); $preamble = sprintf( t('You\'ve received a friend suggestion from \'%s\' at %s'), $params['source_name'], $sitename); $epreamble = sprintf( t('You\'ve received %s for %s from %s.'), '[url=$itemlink]' . t('a friend suggestion') . '[/url]', @@ -237,9 +243,12 @@ intval($params['uid']), LOGGER_DEBUG); $datarray['preamble'] = $preamble; $datarray['sitename'] = $sitename; $datarray['siteurl'] = $siteurl; + $datarray['type'] = $params['type']; + $datarray['parent'] = $params['parent']; $datarray['source_name'] = $params['source_name']; $datarray['source_link'] = $params['source_link']; $datarray['source_photo'] = $params['source_photo']; + $datarray['uid'] = $params['uid']; $datarray['username'] = $params['to_name']; $datarray['hsitelink'] = $hsitelink; $datarray['tsitelink'] = $tsitelink; -- cgit v1.2.3 From 4dd4a2258235cfafc0d5a4f87d116755ebe52ead Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 28 Feb 2012 14:52:23 -0800 Subject: From Tobias H - catch some irregularities caused by cut/paste code --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 7d52571c2..250d023ce 100755 --- a/include/items.php +++ b/include/items.php @@ -2424,7 +2424,7 @@ function local_delivery($importer,$data) { // This is my contact on another system, but it's really me. // Turn this into a wall post. - if($contact['remote_self']) + if($importer['remote_self']) $datarray['wall'] = 1; $datarray['parent-uri'] = $item_id; -- cgit v1.2.3 From 21803e0cd33d51cd634d0147409f0a6529441c8e Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 28 Feb 2012 14:54:17 -0800 Subject: call time pass by reference deprecated --- include/html2bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 65920380b..51d629940 100755 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -10,7 +10,7 @@ Originally made for the syncom project: http://wiki.piratenpartei.de/Syncom function node2bbcode(&$doc, $oldnode, $attributes, $startbb, $endbb) { do { - $done = node2bbcodesub(&$doc, $oldnode, $attributes, $startbb, $endbb); + $done = node2bbcodesub($doc, $oldnode, $attributes, $startbb, $endbb); } while ($done); } -- cgit v1.2.3 From bbebb4c2a050f22e9aa51cb123359b169bcb3b3c Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 29 Feb 2012 18:19:08 -0800 Subject: notification enhancements --- include/enotify.php | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index 76e7eb9dc..80cb7d8fa 100755 --- a/include/enotify.php +++ b/include/enotify.php @@ -25,6 +25,12 @@ function notification($params) { $title = $body = ''; } + if($params['otype'] === 'item') + $possess_desc = t('%s post'); + if($params['otype'] == 'photo') + $possess_desc = t('%s photo'); + + if($params['type'] == NOTIFY_MAIL) { $subject = sprintf( t('[Friendica:Notify] New mail received at %s'),$sitename); @@ -41,7 +47,26 @@ function notification($params) { // logger("notification: params = " . print_r($params, true), LOGGER_DEBUG); $parent_id = $params['parent']; + + + // if it's a post figure out who's post it is. + + $p = null; + + if($params['otype'] === 'item' && $parent_id) { + $p = q("select * from item where id = %d and uid = %d limit 1", + intval($parent_id), + intval($params['uid']) + ); + } + + $dest_str = sprintf($possess_desc,'a'); + if($p) + $dest_str = sprintf($possess_desc,sprintf( t("%s's"),$p[0]['author-name'])); + if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall']) + $dest_str = sprintf($possess_desc, t('your') ); + // Some mail softwares relies on subject field for threading. // So, we cannot have different subjects for notifications of the same thread. // Before this we have the name of the replier on the subject rendering @@ -49,7 +74,7 @@ function notification($params) { $subject = sprintf( t('[Friendica:Notify] Comment to conversation #%d by %s'), $parent_id, $params['source_name']); $preamble = sprintf( t('%s commented on an item/conversation you have been following.'), $params['source_name']); - $epreamble = sprintf( t('%s commented in %s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . t('a watched conversation') . '[/url]'); + $epreamble = sprintf( t('%s commented on %s.'), '[url=' . $params['source_link'] . ']' . $params['source_name'] . '[/url]', '[url=$itemlink]' . $dest_str . '[/url]'); $sitelink = t('Please visit %s to view and/or reply to the conversation.'); $tsitelink = sprintf( $sitelink, $siteurl ); @@ -149,6 +174,7 @@ function notification($params) { $datarray['date'] = datetime_convert(); $datarray['uid'] = $params['uid']; $datarray['link'] = $itemlink; + $datarray['parent'] = $parent_id; $datarray['type'] = $params['type']; $datarray['verb'] = $params['verb']; $datarray['otype'] = $params['otype']; @@ -157,8 +183,8 @@ function notification($params) { // create notification entry in DB - $r = q("insert into notify (hash,name,url,photo,date,uid,link,type,verb,otype) - values('%s','%s','%s','%s','%s',%d,'%s',%d,'%s','%s')", + $r = q("insert into notify (hash,name,url,photo,date,uid,link,parent,type,verb,otype) + values('%s','%s','%s','%s','%s',%d,'%s',%d,%d,'%s','%s')", dbesc($datarray['hash']), dbesc($datarray['name']), dbesc($datarray['url']), @@ -166,6 +192,7 @@ function notification($params) { dbesc($datarray['date']), intval($datarray['uid']), dbesc($datarray['link']), + intval($datarray['parent']), intval($datarray['type']), dbesc($datarray['verb']), dbesc($datarray['otype']) -- cgit v1.2.3 From bd2c8c92f1b30d8f811bd4aab0fe3a2c5496ec61 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 29 Feb 2012 19:23:01 -0800 Subject: yet more work on notifications --- include/enotify.php | 13 +++++++----- include/items.php | 57 +++++++++++++++++++++++++++++++---------------------- include/text.php | 13 ++++++++++++ 3 files changed, 54 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/enotify.php b/include/enotify.php index 80cb7d8fa..a505f1f04 100755 --- a/include/enotify.php +++ b/include/enotify.php @@ -25,11 +25,8 @@ function notification($params) { $title = $body = ''; } - if($params['otype'] === 'item') - $possess_desc = t('%s post'); - if($params['otype'] == 'photo') - $possess_desc = t('%s photo'); - + // e.g. "your post", "David's photo", etc. + $possess_desc = t('%s '); if($params['type'] == NOTIFY_MAIL) { @@ -60,10 +57,16 @@ function notification($params) { ); } + $possess_desc = str_replace('',item_post_type($p[0]),$possess_desc); + + // "a post" $dest_str = sprintf($possess_desc,'a'); + + // "George Bull's post" if($p) $dest_str = sprintf($possess_desc,sprintf( t("%s's"),$p[0]['author-name'])); + // "your post" if($p[0]['owner-name'] == $p[0]['author-name'] && $p[0]['wall']) $dest_str = sprintf($possess_desc, t('your') ); diff --git a/include/items.php b/include/items.php index 250d023ce..a1254e165 100755 --- a/include/items.php +++ b/include/items.php @@ -2325,35 +2325,44 @@ function local_delivery($importer,$data) { if(count($myconv)) { $importer_url = $a->get_baseurl() . '/profile/' . $importer['nickname']; - foreach($myconv as $conv) { - if(! link_compare($conv['author-link'],$importer_url)) - continue; + // first make sure this isn't our own post coming back to us from a wall-to-wall event + if(! link_compare($datarray['author-link'],$importer_url)) { - require_once('include/enotify.php'); - $conv_parent = $conv['parent']; - - notification(array( - 'type' => NOTIFY_COMMENT, - 'notify_flags' => $importer['notify-flags'], - 'language' => $importer['language'], - 'to_name' => $importer['username'], - 'to_email' => $importer['email'], - 'uid' => $importer['importer_uid'], - 'item' => $datarray, - 'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id, - 'source_name' => stripslashes($datarray['author-name']), - 'source_link' => $datarray['author-link'], - 'source_photo' => ((link_compare($datarray['author-link'],$importer['url'])) - ? $importer['thumb'] : $datarray['author-avatar']), - 'verb' => ACTIVITY_POST, - 'otype' => 'item', - 'parent' => $conv_parent, + foreach($myconv as $conv) { - )); + // now if we find a match, it means we're in this conversation + + if(! link_compare($conv['author-link'],$importer_url)) + continue; - break; + require_once('include/enotify.php'); + + $conv_parent = $conv['parent']; + + notification(array( + 'type' => NOTIFY_COMMENT, + 'notify_flags' => $importer['notify-flags'], + 'language' => $importer['language'], + 'to_name' => $importer['username'], + 'to_email' => $importer['email'], + 'uid' => $importer['importer_uid'], + 'item' => $datarray, + 'link' => $a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $posted_id, + 'source_name' => stripslashes($datarray['author-name']), + 'source_link' => $datarray['author-link'], + 'source_photo' => ((link_compare($datarray['author-link'],$importer['url'])) + ? $importer['thumb'] : $datarray['author-avatar']), + 'verb' => ACTIVITY_POST, + 'otype' => 'item', + 'parent' => $conv_parent, + + )); + + // only send one notification + break; + } } } } diff --git a/include/text.php b/include/text.php index 1f5d4a3e1..81e22527a 100755 --- a/include/text.php +++ b/include/text.php @@ -1201,3 +1201,16 @@ function reltoabs($text, $base) return $text; } +function item_post_type($item) { + if(intval($item['event-id'])) + return t('event'); + if(strlen($item['resource-id'])) + return t('photo'); + if(strlen($item['verb']) && $item['verb'] !== ACTIVITY_POST) + return t('activity'); + if($item['id'] != $item['parent']) + return t('comment'); + return t('post'); +} + + -- cgit v1.2.3 From c462ed9fc50e2c2a60e8cb01314a7d5fa498b412 Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Thu, 1 Mar 2012 11:32:49 +0100 Subject: template proc: avoid a notice and allow template name to include to be passed with a variable value --- include/template_processor.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/template_processor.php b/include/template_processor.php index 28c3f07dd..b4d444e1c 100755 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -116,7 +116,15 @@ * {{ inc [with $var1=$var2] }}{{ endinc }} */ private function _replcb_inc($args){ - list($tplfile, $newctx) = array_map('trim', explode("with",$args[2])); + if (strpos($args[2],"with")) { + list($tplfile, $newctx) = array_map('trim', explode("with",$args[2])); + } else { + $tplfile = trim($args[2]); + $newctx = null; + } + + if ($tplfile[0]=="$") $tplfile = $this->_get_var($tplfile); + $this->_push_stack(); $r = $this->r; if (!is_null($newctx)) { -- cgit v1.2.3 From e0c659b34b8992111bcc64d3f0eea75dfa193412 Mon Sep 17 00:00:00 2001 From: Alexander Kampmann Date: Thu, 1 Mar 2012 11:44:33 +0100 Subject: Enabled automated doc building. Changes: -build.xml, phing build file -@package tags at acl_selector.php and db_update.php -added documentation and some IDE files to .gitignore -automated tool to find files that corrupt the doc build process -removed ansi characters from SSH1.php, docBlox could not handle them --- include/acl_selectors.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 6070b7db2..67d8cebde 100755 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -1,6 +1,11 @@ Date: Thu, 1 Mar 2012 11:46:08 +0100 Subject: conversation: remove templating items in code and move it to template. --- include/conversation.php | 197 +++++++++++++++++++++++++---------------------- 1 file changed, 103 insertions(+), 94 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index 2ef37694d..f4740688c 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -6,11 +6,6 @@ function localize_item(&$item){ $Text = $item['body']; - - - // find private image (w/data url) if present and convert image - // link to a magic-auth redirect. - $saved_image = ''; $img_start = strpos($Text,'[img]data:'); $img_end = strpos($Text,'[/img]'); @@ -184,6 +179,7 @@ function localize_item(&$item){ * that are based on unique features of the calling module. * */ + if(!function_exists('conversation')){ function conversation(&$a, $items, $mode, $update, $preview = false) { require_once('bbcode.php'); @@ -231,13 +227,13 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $items = $cb['items']; $cmnt_tpl = get_markup_template('comment_item.tpl'); - $tpl = get_markup_template('wall_item.tpl'); - $wallwall = get_markup_template('wallwall_item.tpl'); + $tpl = 'wall_item.tpl'; + $wallwall = 'wallwall_item.tpl'; $hide_comments_tpl = get_markup_template('hide_comments.tpl'); $alike = array(); $dlike = array(); - $o = ""; + // array with html for each thread (parent+comments) $threads = array(); @@ -250,7 +246,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { // "New Item View" on network page or search page results // - just loop through the items and format them minimally for display - $tpl = get_markup_template('search_item.tpl'); + //$tpl = get_markup_template('search_item.tpl'); + $tpl = 'search_item.tpl'; foreach($items as $item) { $threadsid++; @@ -316,43 +313,46 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $body = prepare_body($item,true); - $tmp_item = replace_macros($tpl,array( - '$id' => (($preview) ? 'P0' : $item['item_id']), - '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - '$profile_url' => $profile_link, - '$item_photo_menu' => item_photo_menu($item), - '$name' => template_escape($profile_name), - '$sparkle' => $sparkle, - '$lock' => $lock, - '$thumb' => $profile_avatar, - '$title' => template_escape($item['title']), - '$body' => template_escape($body), - '$ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - '$lock' => $lock, - '$location' => template_escape($location), - '$indent' => '', - '$owner_name' => template_escape($owner_name), - '$owner_url' => $owner_url, - '$owner_photo' => $owner_photo, - '$plink' => get_plink($item), - '$edpost' => false, - '$isstarred' => $isstarred, - '$star' => $star, - '$drop' => $drop, - '$vote' => $likebuttons, - '$like' => '', - '$dislike' => '', - '$comment' => '', - '$conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), - '$previewing' => $previewing, - '$wait' => t('Please wait'), - )); + //$tmp_item = replace_macros($tpl,array( + $tmp_item = array( + 'template' => $tpl, + 'id' => (($preview) ? 'P0' : $item['item_id']), + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'profile_url' => $profile_link, + 'item_photo_menu' => item_photo_menu($item), + 'name' => template_escape($profile_name), + 'sparkle' => $sparkle, + 'lock' => $lock, + 'thumb' => $profile_avatar, + 'title' => template_escape($item['title']), + 'body' => template_escape($body), + 'text' => strip_tags(template_escape($body)), + 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'lock' => $lock, + 'location' => template_escape($location), + 'indent' => '', + 'owner_name' => template_escape($owner_name), + 'owner_url' => $owner_url, + 'owner_photo' => $owner_photo, + 'plink' => get_plink($item), + 'edpost' => false, + 'isstarred' => $isstarred, + 'star' => $star, + 'drop' => $drop, + 'vote' => $likebuttons, + 'like' => '', + 'dislike' => '', + 'comment' => '', + 'conv' => (($preview) ? '' : array('href'=> $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))), + 'previewing' => $previewing, + 'wait' => t('Please wait'), + ); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); $threads[$threadsid]['id'] = $item['item_id']; - $threads[$threadsid]['html'] .= $arr['output']; + $threads[$threadsid]['items'] = array($arr['output']); } @@ -385,6 +385,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { } $comments_collapsed = false; + $comment_lastcollapsed = false; + $comment_firstcollapsed = false; $blowhard = 0; $blowhard_count = 0; @@ -438,10 +440,12 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $comments_seen = 0; $comments_collapsed = false; + $comment_lastcollapsed = false; + $comment_firstcollapsed = false; $threadsid++; $threads[$threadsid]['id'] = $item['item_id']; - $threads[$threadsid]['html'] = ""; + $threads[$threadsid]['items'] = array(); } else { @@ -449,6 +453,8 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if((! $toplevelpost) && (! $toplevelprivate) && ($item['private']) && ($profile_owner != local_user())) continue; $comments_seen ++; + $comment_lastcollapsed = false; + $comment_firstcollapsed = false; } $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false); @@ -456,23 +462,17 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) { - if(! $comments_collapsed) { - - // IMPORTANT: the closing in the hide_comments template - // is supplied below in code. - $threads[$threadsid]['html'] .= replace_macros($hide_comments_tpl,array( - '$id' => $item['parent'], - '$num_comments' => sprintf( tt('%d comment','%d comments',$comments[$item['parent']]), - $comments[$item['parent']]), - '$display' => 'none', - '$hide_text' => t('show more') - )); + if (!$comments_collapsed){ + $threads[$threadsid]['num_comments'] = sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),$comments[$item['parent']] ); + $threads[$threadsid]['hide_text'] = t('show more'); $comments_collapsed = true; + $comment_firstcollapsed = true; } } if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) { - $threads[$threadsid]['html'] .= ''; + + $comment_lastcollapsed = true; } $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; @@ -649,63 +649,72 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { // Build the HTML $body = prepare_body($item,true); + //$tmp_item = replace_macros($template, + $tmp_item = array( + // collapse comments in template. I don't like this much... + 'comment_firstcollapsed' => $comment_firstcollapsed, + 'comment_lastcollapsed' => $comment_lastcollapsed, + // template to use to render item (wall, walltowall, search) + 'template' => $template, + + 'type' => implode("",array_slice(split("/",$item['verb']),-1)), + 'tags' => $tags, + 'body' => template_escape($body), + 'text' => strip_tags(template_escape($body)), + 'id' => $item['item_id'], + 'linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), + 'olinktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), + 'to' => t('to'), + 'wall' => t('Wall-to-Wall'), + 'vwall' => t('via Wall-To-Wall:'), + 'profile_url' => $profile_link, + 'item_photo_menu' => item_photo_menu($item), + 'name' => template_escape($profile_name), + 'thumb' => $profile_avatar, + 'osparkle' => $osparkle, + 'sparkle' => $sparkle, + 'title' => template_escape($item['title']), + 'ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), + 'lock' => $lock, + 'location' => template_escape($location), + 'indent' => $indent, + 'owner_url' => $owner_url, + 'owner_photo' => $owner_photo, + 'owner_name' => template_escape($owner_name), + 'plink' => get_plink($item), + 'edpost' => $edpost, + 'isstarred' => $isstarred, + 'star' => $star, + 'drop' => $drop, + 'vote' => $likebuttons, + 'like' => $like, + 'dislike' => $dislike, + 'comment' => $comment, + 'previewing' => $previewing, + 'wait' => t('Please wait'), - $tmp_item = replace_macros($template,array( - '$type' => implode("",array_slice(explode("/",$item['verb']),-1)), - '$tags' => $tags, - '$body' => template_escape($body), - '$id' => $item['item_id'], - '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])), - '$olinktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['owner-link'])) ? $item['owner-link'] : $item['url'])), - '$to' => t('to'), - '$wall' => t('Wall-to-Wall'), - '$vwall' => t('via Wall-To-Wall:'), - '$profile_url' => $profile_link, - '$item_photo_menu' => item_photo_menu($item), - '$name' => template_escape($profile_name), - '$thumb' => $profile_avatar, - '$osparkle' => $osparkle, - '$sparkle' => $sparkle, - '$title' => template_escape($item['title']), - '$ago' => (($item['app']) ? sprintf( t('%s from %s'),relative_date($item['created']),$item['app']) : relative_date($item['created'])), - '$lock' => $lock, - '$location' => template_escape($location), - '$indent' => $indent, - '$owner_url' => $owner_url, - '$owner_photo' => $owner_photo, - '$owner_name' => template_escape($owner_name), - '$plink' => get_plink($item), - '$edpost' => $edpost, - '$isstarred' => $isstarred, - '$star' => $star, - '$drop' => $drop, - '$vote' => $likebuttons, - '$like' => $like, - '$dislike' => $dislike, - '$comment' => $comment, - '$previewing' => $previewing, - '$wait' => t('Please wait'), - - )); + ); $arr = array('item' => $item, 'output' => $tmp_item); call_hooks('display_item', $arr); - $threads[$threadsid]['html'] .= $arr['output']; + $threads[$threadsid]['items'][] = $arr['output']; } } } - $page_template = get_markup_template("conversation.tpl"); $o .= replace_macros($page_template, array( + '$baseurl' => $a->get_baseurl(), + '$mode' => $mode, + '$user' => $a->user, '$threads' => $threads, '$dropping' => ($dropping?t('Delete Selected Items'):False), )); return $o; -} +}} function best_link_url($item,&$sparkle) { -- cgit v1.2.3 From 58e3372b23b286334e5195b1b8f70448715ed493 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 1 Mar 2012 18:49:23 -0800 Subject: probe for very old (0.97 or 1.0) RSS feed with an incorrect or generic content-type --- include/Scrape.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/Scrape.php b/include/Scrape.php index 4c4ad3cdb..8344aa737 100755 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -255,6 +255,11 @@ function scrape_feed($url) { } } } + // perhaps an RSS version 1 feed with a generic or incorrect content-type? + if(stristr($s,'')) { + $ret['feed_rss'] = $url; + return $ret; + } } try { -- cgit v1.2.3 From f1bf6dcdfb89bf3c21e498ba3d76c600dafed934 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 2 Mar 2012 01:24:20 -0800 Subject: expand multiple heart smilies e.g. <3333 --- include/text.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/text.php b/include/text.php index 81e22527a..4276b7fcb 100755 --- a/include/text.php +++ b/include/text.php @@ -786,6 +786,7 @@ function smilies($s, $sample = false) { } } else { + $params['string'] = preg_replace_callback('/<(3+)/','preg_heart',$params['string']); $s = str_replace($params['texts'],$params['icons'],$params['string']); } @@ -804,7 +805,18 @@ function smile_decode($m) { return(str_replace($m[1],base64url_decode($m[1]),$m[0])); } +// expand <3333 to the correct number of hearts +function preg_heart($x) { + $a = get_app(); + if(strlen($x[1]) == 1) + return $x[0]; + $t = ''; + for($cnt = 0; $cnt < strlen($x[1]); $cnt ++) + $t .= '<3'; + $r = str_replace($x[0],$t,$x[0]); + return $r; +} if(! function_exists('day_translate')) { -- cgit v1.2.3 From 60e5dda1b5e1be36a15c45ded2635340087a0b0f Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 2 Mar 2012 12:24:35 +0100 Subject: template proc: first optimization --- include/template_processor.php | 31 ++++++++++++++++++++++--------- include/text.php | 8 +++++++- 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/template_processor.php b/include/template_processor.php index b4d444e1c..a80a3997a 100755 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -1,5 +1,5 @@ stack[] = array($this->r, $this->search, $this->replace, $this->nodes); + $this->stack[] = array($this->r, $this->nodes); } private function _pop_stack(){ - list($this->r, $this->search, $this->replace, $this->nodes) = array_pop($this->stack); + list($this->r, $this->nodes) = array_pop($this->stack); } - private function _get_var($name){ - $keys = array_map('trim',explode(".",$name)); + private function _get_var($name, $retNoKey=false){ + $keys = array_map('trim',explode(".",$name)); + if ($retNoKey && !array_key_exists($keys[0], $this->r)) return KEY_NOT_EXISTS; $val = $this->r; foreach($keys as $k) { $val = (isset($val[$k]) ? $val[$k] : null); @@ -194,13 +195,24 @@ return str_replace($this->search,$this->replace, $str); }*/ + private function var_replace($s){ + $m = array(); + if (preg_match_all('/\$([a-zA-Z0-9-_]+\.*)+/', $s,$m)){ + foreach($m[0] as $var){ + $val = $this->_get_var($var, true); + if ($val!=KEY_NOT_EXISTS) + $s = str_replace($var, $val, $s); + } + } + return $s; + } public function replace($s, $r) { $this->r = $r; - $this->search = array(); - $this->replace = array(); + /*$this->search = array(); + $this->replace = array();*/ - $this->_build_replace($r, ""); + //$this->_build_replace($r, ""); #$s = str_replace(array("\n","\r"),array("§n§","§r§"),$s); $s = $this->_build_nodes($s); @@ -215,7 +227,8 @@ while($os!=$s && $count<10){ $os=$s; $count++; //$s = $this->_str_replace($s); - $s = str_replace($this->search, $this->replace, $s); + $s = $this->var_replace($s); + //$s = str_replace($this->search, $this->replace, $s); } return template_unescape($s); } diff --git a/include/text.php b/include/text.php index 4276b7fcb..042ee982c 100755 --- a/include/text.php +++ b/include/text.php @@ -14,7 +14,13 @@ if(! function_exists('replace_macros')) { function replace_macros($s,$r) { global $t; - return $t->replace($s,$r); + //$ts = microtime(); + $r = $t->replace($s,$r); + //$tt = microtime() - $ts; + + //$a = get_app(); + //$a->page['debug'] .= "$tt
\n"; + return $r; }} -- cgit v1.2.3 From 0bf087c8957ba28b76b7bc96345908735418a71f Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 2 Mar 2012 12:36:22 +0100 Subject: template proc: remove unused function and commented out code --- include/template_processor.php | 45 +----------------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) (limited to 'include') diff --git a/include/template_processor.php b/include/template_processor.php index a80a3997a..9ac0a1313 100755 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -28,19 +28,6 @@ die(); } - private function _build_replace($r, $prefix){ - - if(is_array($r) && count($r)) { - foreach ($r as $k => $v ) { - if (is_array($v)) { - $this->_build_replace($v, "$prefix$k."); - } else { - $this->search[] = $prefix . $k; - $this->replace[] = $v; - } - } - } - } private function _push_stack(){ $this->stack[] = array($this->r, $this->nodes); @@ -170,30 +157,6 @@ return $s; } - /* - private function _str_replace($str){ - #$this->search,$this->replace, - $searchs = $this->search; - foreach($searchs as $search){ - $search = "|".preg_quote($search)."(\|[a-zA-Z0-9_]*)*|"; - $m = array(); - if (preg_match_all($search, $str,$m)){ - foreach ($m[0] as $match){ - $toks = explode("|",$match); - $val = $this->_get_var($toks[0]); - for($k=1; $k1){ - $str = str_replace( $match, $val, $str); - } - } - } - - } - return str_replace($this->search,$this->replace, $str); - }*/ private function var_replace($s){ $m = array(); @@ -209,12 +172,7 @@ public function replace($s, $r) { $this->r = $r; - /*$this->search = array(); - $this->replace = array();*/ - - //$this->_build_replace($r, ""); - #$s = str_replace(array("\n","\r"),array("§n§","§r§"),$s); $s = $this->_build_nodes($s); $s = preg_replace_callback('/\|\|([0-9]+)\|\|/', array($this, "_replcb_node"), $s); @@ -222,13 +180,12 @@ // remove comments block $s = preg_replace('/{#[^#]*#}/', "" , $s); + // replace strings recursively (limit to 10 loops) $os = ""; $count=0; while($os!=$s && $count<10){ $os=$s; $count++; - //$s = $this->_str_replace($s); $s = $this->var_replace($s); - //$s = str_replace($this->search, $this->replace, $s); } return template_unescape($s); } -- cgit v1.2.3 From aef737f37637270b4f79ea390ee23a61f7fcb4ba Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Fri, 2 Mar 2012 15:53:48 +0100 Subject: template proc: allow isolation of var name between [ and ] $var.name -> $[var.name] --- include/template_processor.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/template_processor.php b/include/template_processor.php index 9ac0a1313..111fc5849 100755 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -160,13 +160,15 @@ private function var_replace($s){ $m = array(); - if (preg_match_all('/\$([a-zA-Z0-9-_]+\.*)+/', $s,$m)){ + if (preg_match_all('/\$\[{0,1}([a-zA-Z0-9-_]+\.*)+\]{0,1}/', $s,$m)){ foreach($m[0] as $var){ - $val = $this->_get_var($var, true); + $varn = str_replace(array("[","]"), array("",""), $var); + $val = $this->_get_var($varn, true); if ($val!=KEY_NOT_EXISTS) $s = str_replace($var, $val, $s); } } + return $s; } -- cgit v1.2.3 From 685686b3e81e53264b4946f54904e8f5323da2ea Mon Sep 17 00:00:00 2001 From: Fabio Comuni Date: Sat, 3 Mar 2012 00:00:38 +0100 Subject: template proc: fix variables regexp --- include/template_processor.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/template_processor.php b/include/template_processor.php index 111fc5849..8671587fc 100755 --- a/include/template_processor.php +++ b/include/template_processor.php @@ -160,7 +160,16 @@ private function var_replace($s){ $m = array(); - if (preg_match_all('/\$\[{0,1}([a-zA-Z0-9-_]+\.*)+\]{0,1}/', $s,$m)){ + /** regexp: + * \$ literal $ + * (\[)? optional open square bracket + * ([a-zA-Z0-9-_]+\.?)+ var name, followed by optional + * dot, repeated at least 1 time + * (?(1)\]) if there was opened square bracket + * (subgrup 1), match close bracket + */ + if (preg_match_all('/\$(\[)?([a-zA-Z0-9-_]+\.?)+(?(1)\])/', $s,$m)){ + foreach($m[0] as $var){ $varn = str_replace(array("[","]"), array("",""), $var); $val = $this->_get_var($varn, true); -- cgit v1.2.3 From 4134fd3dcee1b26b888c89c47f798fd3fd058064 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 4 Mar 2012 16:26:16 -0800 Subject: unused replacement variable displays %1 in all html2bbcode 'code' blocks --- include/html2bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 51d629940..32a90d7d6 100755 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -212,7 +212,7 @@ function html2bbcode($message) node2bbcode($doc, 'audio', array('src'=>'/(.+)/'), '[audio]$1', '[/audio]'); node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), '[iframe]$1', '[/iframe]'); - node2bbcode($doc, 'code', array(), '[code]$1', '[/code]'); + node2bbcode($doc, 'code', array(), '[code]', '[/code]'); $message = $doc->saveHTML(); -- cgit v1.2.3 From fba089012a3b4cd8c2969e111173bab0d58b6750 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 4 Mar 2012 18:50:32 -0800 Subject: correct owner info from misconfigured installs, duepuntozero title block misplaced in editplain mode --- include/items.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index a1254e165..3c55fbb4f 100755 --- a/include/items.php +++ b/include/items.php @@ -1747,6 +1747,18 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; + + if(x($datarray,'owner-link') && strlen($datarray['owner-link']) && (! link_compare($datarray['owner-link'],$contact['url']))) { + // The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery, + // but otherwise there's a possible data mixup on the sender's system. + // the tgroup delivery code called from item_store will correct it if it's a forum, + // but we're going to unconditionally correct it here so that the post will always be owned by our contact. + logger('local_delivery: Correcting item owner.', LOGGER_DEBUG); + $datarray['owner-name'] = $contact['name']; + $datarray['owner-link'] = $contact['url']; + $datarray['owner-avatar'] = $contact['thumb']; + } + $r = item_store($datarray); continue; @@ -2439,6 +2451,18 @@ function local_delivery($importer,$data) { $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['importer_uid']; $datarray['contact-id'] = $importer['id']; + + if(x($datarray,'owner-link') && strlen($datarray['owner-link']) && (! link_compare($datarray['owner-link'],$importer['url']))) { + // The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery, + // but otherwise there's a possible data mixup on the sender's system. + // the tgroup delivery code called from item_store will correct it if it's a forum, + // but we're going to unconditionally correct it here so that the post will always be owned by our contact. + logger('local_delivery: Correcting item owner.', LOGGER_DEBUG); + $datarray['owner-name'] = $importer['senderName']; + $datarray['owner-link'] = $importer['url']; + $datarray['owner-avatar'] = $importer['thumb']; + } + $r = item_store($datarray); continue; } -- cgit v1.2.3 From c37ffd2999453de17bd6b0c98b708a0f55bacdc7 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 5 Mar 2012 15:04:43 -0800 Subject: can_write_wall documentation --- include/security.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index bc2c9f0bf..6b8128bdd 100755 --- a/include/security.php +++ b/include/security.php @@ -108,14 +108,18 @@ function can_write_wall(&$a,$owner) { if(remote_user()) { - // user remembered decision and avoid a DB lookup for each and every display item + // use remembered decision and avoid a DB lookup for each and every display item // DO NOT use this function if there are going to be multiple owners + // We have a contact-id for an authenticated remote user, this block determines if the contact + // belongs to this page owner, and has the necessary permissions to post content + if($verified === 2) return true; elseif($verified === 1) return false; else { + $r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `user`.`uid` = `contact`.`uid` WHERE `contact`.`uid` = %d AND `contact`.`id` = %d AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `user`.`blockwall` = 0 AND `readonly` = 0 AND ( `contact`.`rel` IN ( %d , %d ) OR `user`.`page-flags` = %d ) LIMIT 1", @@ -125,6 +129,7 @@ function can_write_wall(&$a,$owner) { intval(CONTACT_IS_FRIEND), intval(PAGE_COMMUNITY) ); + if(count($r)) { $verified = 2; return true; -- cgit v1.2.3 From 23718bfc259c00e87e3845ba4b1ead52ca7c6559 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 6 Mar 2012 02:17:55 -0800 Subject: prevent duplicate likes --- include/items.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/items.php b/include/items.php index 3c55fbb4f..fdff6b642 100755 --- a/include/items.php +++ b/include/items.php @@ -1595,6 +1595,14 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) { $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; + // only one like or dislike per person + $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 limit 1", + intval($datarray['uid']), + intval($datarray['contact-id']), + dbesc($datarray['verb']) + ); + if($r && count($r)) + continue; } if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) { @@ -2148,6 +2156,14 @@ function local_delivery($importer,$data) { $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; $datarray['last-child'] = 0; + // only one like or dislike per person + $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 limit 1", + intval($datarray['uid']), + intval($datarray['contact-id']), + dbesc($datarray['verb']) + ); + if($r && count($r)) + continue; } if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) { @@ -2297,6 +2313,15 @@ function local_delivery($importer,$data) { if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) { $datarray['type'] = 'activity'; $datarray['gravity'] = GRAVITY_LIKE; + // only one like or dislike per person + $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 limit 1", + intval($datarray['uid']), + intval($datarray['contact-id']), + dbesc($datarray['verb']) + ); + if($r && count($r)) + continue; + } if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) { -- cgit v1.2.3 From eec4cff84be630bf3a4165321a423c29ed7926e9 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 6 Mar 2012 04:28:45 -0800 Subject: remove "smilie" expansion for Diaspora logo --- include/text.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 042ee982c..c8c03174e 100755 --- a/include/text.php +++ b/include/text.php @@ -737,7 +737,7 @@ function smilies($s, $sample = false) { ':headdesk', '~friendika', '~friendica', - 'Diaspora*' +// 'Diaspora*' ); $icons = array( @@ -778,7 +778,7 @@ function smilies($s, $sample = false) { ':headdesk', '~friendika ~friendika', '~friendica ~friendica', - 'DiasporaDiaspora*', +// 'DiasporaDiaspora*', ); -- cgit v1.2.3 From a265afe7eb43bfe494669ee245c97bd7460fb671 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 6 Mar 2012 20:44:53 +0000 Subject: added beard smileys --- include/text.php | 43 ++++++++----------------------------------- 1 file changed, 8 insertions(+), 35 deletions(-) mode change 100755 => 100644 include/text.php (limited to 'include') diff --git a/include/text.php b/include/text.php old mode 100755 new mode 100644 index c8c03174e..2667ddddc --- a/include/text.php +++ b/include/text.php @@ -14,13 +14,7 @@ if(! function_exists('replace_macros')) { function replace_macros($s,$r) { global $t; - //$ts = microtime(); - $r = $t->replace($s,$r); - //$tt = microtime() - $ts; - - //$a = get_app(); - //$a->page['debug'] .= "$tt
\n"; - return $r; + return $t->replace($s,$r); }} @@ -737,7 +731,9 @@ function smilies($s, $sample = false) { ':headdesk', '~friendika', '~friendica', -// 'Diaspora*' + 'Diaspora*', + ':beard', + ':whitebeard' ); $icons = array( @@ -778,7 +774,9 @@ function smilies($s, $sample = false) { ':headdesk', '~friendika ~friendika', '~friendica ~friendica', -// 'DiasporaDiaspora*', + 'DiasporaDiaspora*', + ':beard', + ':whitebeard' ); @@ -792,7 +790,6 @@ function smilies($s, $sample = false) { } } else { - $params['string'] = preg_replace_callback('/<(3+)/','preg_heart',$params['string']); $s = str_replace($params['texts'],$params['icons'],$params['string']); } @@ -811,18 +808,7 @@ function smile_decode($m) { return(str_replace($m[1],base64url_decode($m[1]),$m[0])); } -// expand <3333 to the correct number of hearts -function preg_heart($x) { - $a = get_app(); - if(strlen($x[1]) == 1) - return $x[0]; - $t = ''; - for($cnt = 0; $cnt < strlen($x[1]); $cnt ++) - $t .= '<3'; - $r = str_replace($x[0],$t,$x[0]); - return $r; -} if(! function_exists('day_translate')) { @@ -1014,7 +1000,7 @@ function lang_selector() { } $ll = substr($l,5); $ll = substr($ll,0,strrpos($ll,'/')); - $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? ' selected="selected" ' : ''); + $selected = (($ll === $lang && (x($_SESSION['language']))) ? ' selected="selected" ' : ''); $o .= ''; } } @@ -1219,16 +1205,3 @@ function reltoabs($text, $base) return $text; } -function item_post_type($item) { - if(intval($item['event-id'])) - return t('event'); - if(strlen($item['resource-id'])) - return t('photo'); - if(strlen($item['verb']) && $item['verb'] !== ACTIVITY_POST) - return t('activity'); - if($item['id'] != $item['parent']) - return t('comment'); - return t('post'); -} - - -- cgit v1.2.3 From 67456bad067dd06c5775979c07c25c767164da36 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 6 Mar 2012 20:50:38 +0000 Subject: Fixed...merged with mainline THEN added beards. --- include/text.php | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index 2667ddddc..e7c95d35c 100644 --- a/include/text.php +++ b/include/text.php @@ -14,7 +14,13 @@ if(! function_exists('replace_macros')) { function replace_macros($s,$r) { global $t; - return $t->replace($s,$r); + //$ts = microtime(); + $r = $t->replace($s,$r); + //$tt = microtime() - $ts; + + //$a = get_app(); + //$a->page['debug'] .= "$tt
\n"; + return $r; }} @@ -731,9 +737,10 @@ function smilies($s, $sample = false) { ':headdesk', '~friendika', '~friendica', - 'Diaspora*', +// 'Diaspora*' ':beard', ':whitebeard' + ); $icons = array( @@ -774,10 +781,9 @@ function smilies($s, $sample = false) { ':headdesk', '~friendika ~friendika', '~friendica ~friendica', - 'DiasporaDiaspora*', +// 'DiasporaDiaspora*', ':beard', ':whitebeard' - ); $params = array('texts' => $texts, 'icons' => $icons, 'string' => $s); @@ -790,6 +796,7 @@ function smilies($s, $sample = false) { } } else { + $params['string'] = preg_replace_callback('/<(3+)/','preg_heart',$params['string']); $s = str_replace($params['texts'],$params['icons'],$params['string']); } @@ -808,7 +815,18 @@ function smile_decode($m) { return(str_replace($m[1],base64url_decode($m[1]),$m[0])); } +// expand <3333 to the correct number of hearts +function preg_heart($x) { + $a = get_app(); + if(strlen($x[1]) == 1) + return $x[0]; + $t = ''; + for($cnt = 0; $cnt < strlen($x[1]); $cnt ++) + $t .= '<3'; + $r = str_replace($x[0],$t,$x[0]); + return $r; +} if(! function_exists('day_translate')) { @@ -1000,7 +1018,7 @@ function lang_selector() { } $ll = substr($l,5); $ll = substr($ll,0,strrpos($ll,'/')); - $selected = (($ll === $lang && (x($_SESSION['language']))) ? ' selected="selected" ' : ''); + $selected = (($ll === $lang && (x($_SESSION, 'language'))) ? ' selected="selected" ' : ''); $o .= ''; } } @@ -1205,3 +1223,16 @@ function reltoabs($text, $base) return $text; } +function item_post_type($item) { + if(intval($item['event-id'])) + return t('event'); + if(strlen($item['resource-id'])) + return t('photo'); + if(strlen($item['verb']) && $item['verb'] !== ACTIVITY_POST) + return t('activity'); + if($item['id'] != $item['parent']) + return t('comment'); + return t('post'); +} + + -- cgit v1.2.3 From 8fb0ea4048745c09ece6c84f23bffdccfc59d67d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 6 Mar 2012 14:27:53 -0800 Subject: bugs #312, #313 --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index f4740688c..b458923e5 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -217,7 +217,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { if($update) $return_url = $_SESSION['return_url']; else - $return_url = $_SESSION['return_url'] = $a->cmd; + $return_url = $_SESSION['return_url'] = $a->query_string; load_contact_links(local_user()); -- cgit v1.2.3 From 6a5c4bab9c4e06c65fb68b0586853f169197ab0b Mon Sep 17 00:00:00 2001 From: tommy tomson Date: Wed, 7 Mar 2012 00:07:27 +0100 Subject: messages-menu translation, add scroll-to-top and theme-bug-report in theme --- include/nav.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/nav.php b/include/nav.php index 511ca07fc..aadfa82fd 100755 --- a/include/nav.php +++ b/include/nav.php @@ -122,6 +122,9 @@ function nav(&$a) { } $nav['messages'] = array('message', t('Messages'), "", t('Private mail')); + $nav['messages']['inbox'] = array('message', t('Inbox'), "", t('Inbox')); + $nav['messages']['outbox']= array('message/sent', t('Outbox'), "", t('Outbox')); + $nav['messages']['new'] = array('message/new', t('New Message'), "", t('New Message')); if(is_array($a->identities) && count($a->identities) > 1) { $nav['manage'] = array('manage', t('Manage'), "", t('Manage other pages')); -- cgit v1.2.3 From 88cd5800cf2e22f365bc38f567fcc1627e9278a7 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 6 Mar 2012 17:21:14 -0800 Subject: [privacy] rework latest fix --- include/security.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index 6b8128bdd..c04491570 100755 --- a/include/security.php +++ b/include/security.php @@ -159,6 +159,7 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { AND allow_gid = '' AND deny_cid = '' AND deny_gid = '' + AND private = 0 "; /** @@ -199,10 +200,11 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { } $sql = sprintf( - " AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) + " AND (( allow_cid = '' OR allow_cid REGEXP '<%d>' ) AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s') + OR private = 0 ) ", intval($remote_user), intval($remote_user), -- cgit v1.2.3 From 7ad2dd65654f6b1cb17ae98e65c3e95528d29e30 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 6 Mar 2012 17:52:00 -0800 Subject: fix photos after permissions_sql change --- include/security.php | 80 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index c04491570..9042d4d64 100755 --- a/include/security.php +++ b/include/security.php @@ -149,6 +149,77 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { $local_user = local_user(); $remote_user = remote_user(); + /** + * Construct permissions + * + * default permissions - anonymous user + */ + + $sql = " AND allow_cid = '' + AND allow_gid = '' + AND deny_cid = '' + AND deny_gid = '' + "; + + /** + * Profile owner - everything is visible + */ + + if(($local_user) && ($local_user == $owner_id)) { + $sql = ''; + } + + /** + * Authenticated visitor. Unless pre-verified, + * check that the contact belongs to this $owner_id + * and load the groups the visitor belongs to. + * If pre-verified, the caller is expected to have already + * done this and passed the groups into this function. + */ + + elseif($remote_user) { + + if(! $remote_verified) { + $r = q("SELECT id FROM contact WHERE id = %d AND uid = %d AND blocked = 0 LIMIT 1", + intval($remote_user), + intval($owner_id) + ); + if(count($r)) { + $remote_verified = true; + $groups = init_groups_visitor($remote_user); + } + } + if($remote_verified) { + + $gs = '<<>>'; // should be impossible to match + + if(is_array($groups) && count($groups)) { + foreach($groups as $g) + $gs .= '|<' . intval($g) . '>'; + } + + $sql = sprintf( + " AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) + AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) + AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) + AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s') + ", + intval($remote_user), + intval($remote_user), + dbesc($gs), + dbesc($gs) + ); + } + } + return $sql; +} + + +function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) { + + $local_user = local_user(); + $remote_user = remote_user(); + /** * Construct permissions * @@ -200,11 +271,10 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { } $sql = sprintf( - " AND (( allow_cid = '' OR allow_cid REGEXP '<%d>' ) + " AND ( private = 0 OR (( allow_cid = '' OR allow_cid REGEXP '<%d>' ) AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) - AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s') - OR private = 0 ) + AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s'))) ", intval($remote_user), intval($remote_user), @@ -214,4 +284,6 @@ function permissions_sql($owner_id,$remote_verified = false,$groups = null) { } } return $sql; -} \ No newline at end of file +} + + -- cgit v1.2.3 From dd3b3c2454b98225e2251a890095e8a971fdb396 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 7 Mar 2012 15:54:37 -0800 Subject: revup --- include/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/security.php b/include/security.php index 9042d4d64..f469dad66 100755 --- a/include/security.php +++ b/include/security.php @@ -271,7 +271,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) } $sql = sprintf( - " AND ( private = 0 OR (( allow_cid = '' OR allow_cid REGEXP '<%d>' ) + " AND ( private = 0 OR ( private = 1 AND wall = 1 AND ( allow_cid = '' OR allow_cid REGEXP '<%d>' ) AND ( deny_cid = '' OR NOT deny_cid REGEXP '<%d>' ) AND ( allow_gid = '' OR allow_gid REGEXP '%s' ) AND ( deny_gid = '' OR NOT deny_gid REGEXP '%s'))) -- cgit v1.2.3 From 395a9530dcbca95b2f2c7dde9df21ee1981fa19f Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 7 Mar 2012 18:23:55 -0800 Subject: still getting parent relays on remote systems --- include/items.php | 4 ++-- include/notifier.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index fdff6b642..1a7aa6c46 100755 --- a/include/items.php +++ b/include/items.php @@ -1756,7 +1756,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0) $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $contact['id']; - if(x($datarray,'owner-link') && strlen($datarray['owner-link']) && (! link_compare($datarray['owner-link'],$contact['url']))) { + if(! link_compare($datarray['owner-link'],$contact['url'])) { // The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery, // but otherwise there's a possible data mixup on the sender's system. // the tgroup delivery code called from item_store will correct it if it's a forum, @@ -2477,7 +2477,7 @@ function local_delivery($importer,$data) { $datarray['uid'] = $importer['importer_uid']; $datarray['contact-id'] = $importer['id']; - if(x($datarray,'owner-link') && strlen($datarray['owner-link']) && (! link_compare($datarray['owner-link'],$importer['url']))) { + if(! link_compare($datarray['owner-link'],$contact['url'])) { // The item owner info is not our contact. It's OK and is to be expected if this is a tgroup delivery, // but otherwise there's a possible data mixup on the sender's system. // the tgroup delivery code called from item_store will correct it if it's a forum, diff --git a/include/notifier.php b/include/notifier.php index 4765cca06..5b23406fc 100755 --- a/include/notifier.php +++ b/include/notifier.php @@ -201,7 +201,7 @@ function notifier_run($argv, $argc){ // by stringing togther an array of retractions and sending them onward. - $localhost = $a->get_hostname(); + $localhost = str_replace('www.','',$a->get_hostname()); if(strpos($localhost,':')) $localhost = substr($localhost,0,strpos($localhost,':')); -- cgit v1.2.3 From 2050f886cc020c50684df14830bc98e40200309c Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 8 Mar 2012 21:14:41 -0800 Subject: keep tony from talking to himself --- include/conversation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index b458923e5..f1134975a 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -502,7 +502,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $template = $wallwall; $commentww = 'ww'; } - if((! $item['wall']) && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) { + if((! $item['wall']) && (strlen($item['owner-link'])) && (! link_compare($item['owner-link'],$item['author-link']))) { // Could be anybody. -- cgit v1.2.3 From 312c17504515b0f6c77b2e59ef8569dbf8d048fa Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 9 Mar 2012 00:31:17 -0800 Subject: bug in check for private email comment to public conversation prevents authenticated visitor from seeing comments that should be allowed --- include/conversation.php | 31 ++++++++----------------------- include/security.php | 1 + 2 files changed, 9 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/conversation.php b/include/conversation.php index f1134975a..526c6ea00 100755 --- a/include/conversation.php +++ b/include/conversation.php @@ -179,9 +179,11 @@ function localize_item(&$item){ * that are based on unique features of the calling module. * */ - if(!function_exists('conversation')){ + +if(!function_exists('conversation')) { function conversation(&$a, $items, $mode, $update, $preview = false) { + require_once('bbcode.php'); $profile_owner = 0; @@ -418,26 +420,6 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $toplevelprivate = (($toplevelpost && $item['private']) ? true : false); $item_writeable = (($item['writable'] || $item['self']) ? true : false); - // DISABLED - /* - if($blowhard == $item['cid'] && (! $item['self']) && ($mode != 'profile') && ($mode != 'notes')) { - $blowhard_count ++; - if($blowhard_count == 3) { - $o .= '' . ''; - $blowhard_count = 0; - } - // END DISABLED - */ - $comments_seen = 0; $comments_collapsed = false; $comment_lastcollapsed = false; @@ -445,13 +427,16 @@ function conversation(&$a, $items, $mode, $update, $preview = false) { $threadsid++; $threads[$threadsid]['id'] = $item['item_id']; + $threads[$threadsid]['private'] = $item['private']; $threads[$threadsid]['items'] = array(); } else { - // prevent private email from leaking into public conversation - if((! $toplevelpost) && (! $toplevelprivate) && ($item['private']) && ($profile_owner != local_user())) + + // prevent private email reply to public conversation from leaking. + if($item['private'] && ! $threads[$threadsid]['private']) continue; + $comments_seen ++; $comment_lastcollapsed = false; $comment_firstcollapsed = false; diff --git a/include/security.php b/include/security.php index f469dad66..8c536b656 100755 --- a/include/security.php +++ b/include/security.php @@ -283,6 +283,7 @@ function item_permissions_sql($owner_id,$remote_verified = false,$groups = null) ); } } + return $sql; } -- cgit v1.2.3