diff --git a/.gitignore b/.gitignore index 3dfb8a903a..6302bc1c8b 100755 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,11 @@ home.html addon *~ +#ignore documentation, it should be newly built +doc/api + +#ignore config files from eclipse, we don't want IDE files in our repository +.project +.buildpath +.externalToolBuilders +.settings diff --git a/LICENSE b/LICENSE index 65ec68b9c2..15c3e825b6 100755 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010, 2011 the Friendica Project +Copyright (c) 2010-2012 the Friendica Project All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README b/README index e69de29bb2..152d481eac 100644 --- a/README +++ b/README @@ -0,0 +1,4 @@ +Friendica Social Communications Server +====================================== + +Welcome to the free social web. diff --git a/boot.php b/boot.php index bac7861c07..19728b6ba9 100755 --- a/boot.php +++ b/boot.php @@ -9,9 +9,9 @@ require_once('include/nav.php'); require_once('include/cache.php'); define ( 'FRIENDICA_PLATFORM', 'Friendica'); -define ( 'FRIENDICA_VERSION', '2.3.1264' ); +define ( 'FRIENDICA_VERSION', '2.3.1268' ); define ( 'DFRN_PROTOCOL_VERSION', '2.22' ); -define ( 'DB_UPDATE_VERSION', 1128 ); +define ( 'DB_UPDATE_VERSION', 1131 ); define ( 'EOL', "
\r\n" ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); diff --git a/build.xml b/build.xml new file mode 100644 index 0000000000..83c5300264 --- /dev/null +++ b/build.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/database.sql b/database.sql index 349dd2a27b..35c257f021 100755 --- a/database.sql +++ b/database.sql @@ -216,6 +216,7 @@ CREATE TABLE IF NOT EXISTS `item` ( `tag` mediumtext NOT NULL, `attach` mediumtext NOT NULL, `inform` mediumtext NOT NULL, + `file` mediumtext NOT NULL, `location` char(255) NOT NULL, `coord` char(255) NOT NULL, `allow_cid` mediumtext NOT NULL, @@ -262,6 +263,7 @@ CREATE TABLE IF NOT EXISTS `item` ( FULLTEXT KEY `title` (`title`), FULLTEXT KEY `body` (`body`), FULLTEXT KEY `tag` (`tag`), + FULLTEXT KEY `file` (`file`), FULLTEXT KEY `allow_cid` (`allow_cid`), FULLTEXT KEY `allow_gid` (`allow_gid`), FULLTEXT KEY `deny_cid` (`deny_cid`), @@ -752,14 +754,18 @@ CREATE TABLE IF NOT EXISTS `notify` ( `msg` MEDIUMTEXT NOT NULL , `uid` INT NOT NULL , `link` CHAR( 255 ) NOT NULL , +`parent` INT( 11 ) NOT NULL, `seen` TINYINT( 1 ) NOT NULL DEFAULT '0', `verb` CHAR( 255 ) NOT NULL, `otype` CHAR( 16 ) NOT NULL, INDEX ( `hash` ), INDEX ( `type` ), INDEX ( `uid` ), +INDEX ( `link` ), +INDEX ( `parent` ), INDEX ( `seen` ), -INDEX ( `date` ) +INDEX ( `date` ), +INDEX ( `otype` ) ) ENGINE = MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `item_id` ( @@ -844,6 +850,7 @@ CREATE TABLE IF NOT EXISTS `spam` ( `spam` INT NOT NULL DEFAULT '0', `ham` INT NOT NULL DEFAULT '0', `term` CHAR(255) NOT NULL, +`date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', INDEX ( `uid` ), INDEX ( `spam` ), INDEX ( `ham` ), diff --git a/include/Scrape.php b/include/Scrape.php index 4c4ad3cdb9..8344aa7373 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 { diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 6070b7db21..67d8cebdeb 100755 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -1,6 +1,11 @@ (($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) { diff --git a/include/enotify.php b/include/enotify.php index 67e0011b8c..a505f1f040 100755 --- a/include/enotify.php +++ b/include/enotify.php @@ -25,9 +25,12 @@ function notification($params) { $title = $body = ''; } + // e.g. "your post", "David's photo", etc. + $possess_desc = t('%s '); + 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,17 +41,43 @@ 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']; + + + // 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']) + ); + } + + $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') ); + // 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 // 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]'); + $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 ); @@ -57,7 +86,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 +99,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 +110,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 +121,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 +133,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]', @@ -143,6 +177,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']; @@ -151,8 +186,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']), @@ -160,6 +195,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']) @@ -237,9 +273,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; diff --git a/include/items.php b/include/items.php index 7d52571c25..a1254e165a 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']; + foreach($myconv as $conv) { - 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, + // now if we find a match, it means we're in this conversation + + if(! link_compare($conv['author-link'],$importer_url)) + continue; - )); + require_once('include/enotify.php'); + + $conv_parent = $conv['parent']; - break; + 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; + } } } } @@ -2424,7 +2433,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; diff --git a/include/template_processor.php b/include/template_processor.php index 28c3f07ddd..b4d444e1c6 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)) { diff --git a/include/text.php b/include/text.php index 1f5d4a3e12..4276b7fcb3 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')) { @@ -1201,3 +1213,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'); +} + + diff --git a/library/phpsec/Net/SSH1.php b/library/phpsec/Net/SSH1.php index 6986a8450d..7220ee4023 100755 --- a/library/phpsec/Net/SSH1.php +++ b/library/phpsec/Net/SSH1.php @@ -730,8 +730,8 @@ class Net_SSH1 { /** * Reads the output of an interactive shell. * - * Requires PHP 4.3.0 or later due to the use of the stream_select() function. If you see stuff like - * "", you're seeing ANSI escape codes. According to + * Requires PHP 4.3.0 or later due to the use of the stream_select() function. If you see crap, + * you're seeing ANSI escape codes. According to * {@link http://support.microsoft.com/kb/101875 How to Enable ANSI.SYS in a Command Window}, "Windows NT * does not support ANSI escape sequences in Win32 Console applications", so if you're a Windows user, * there's not going to be much recourse. diff --git a/library/spam/b8/storage/storage_frndc.php b/library/spam/b8/storage/storage_frndc.php index cbc6fe81a9..7702c108b3 100644 --- a/library/spam/b8/storage/storage_frndc.php +++ b/library/spam/b8/storage/storage_frndc.php @@ -147,58 +147,8 @@ class b8_storage_frndc extends b8_storage_base public function connect() { - return TRUE; - - # Are we already connected? - if($this->connected === TRUE) - return TRUE; - - # Are we using an existing passed resource? - if($this->config['connection'] === FALSE) { - # ... yes we are, but the connection is not a resource, so return an error - $this->connected = FALSE; - return self::DATABASE_CONNECTION_BAD_RESOURCE; - } - - elseif($this->config['connection'] === NULL) { - - # ... no we aren't so we have to connect. - - if($this->_connection = mysql_connect($this->config['host'], $this->config['user'], $this->config['pass'])) { - if(mysql_select_db($this->config['database'], $this->_connection) === FALSE) { - $this->connected = FALSE; - return self::DATABASE_SELECT_ERROR . ": " . mysql_error(); - } - } - else { - $this->connected = FALSE; - return self::DATABASE_CONNECTION_ERROR; - } - - } - - else { - # ... yes we are - $this->_connection = $this->config['connection']; - } - - # Just in case ... - if($this->_connection === NULL) { - $this->connected = FALSE; - return self::DATABASE_CONNECTION_FAIL; - } - - # Check to see if the wordlist table exists - if(mysql_query('DESCRIBE ' . $this->config['table_name'], $this->_connection) === FALSE) { - $this->connected = FALSE; - return self::DATABASE_TABLE_ACCESS_FAIL . ": " . mysql_error(); - } - - # Everything is okay and connected $this->connected = TRUE; - - # Let's see if this is a b8 database and the version is okay - return $this->check_database(); + return TRUE; } @@ -235,7 +185,7 @@ class b8_storage_frndc extends b8_storage_base # ... and fetch the data $result = q(' - SELECT token, count + SELECT * FROM ' . $this->config['table_name'] . ' WHERE ' . $where . ' AND uid = ' . $uid ); diff --git a/mod/admin.php b/mod/admin.php index 0f600e3126..94bf445032 100755 --- a/mod/admin.php +++ b/mod/admin.php @@ -366,7 +366,7 @@ function admin_page_users_post(&$a){ intval( $uid ) ); } - notice( sprintf( tt("%s user blocked", "%s users blocked/unblocked", count($users)), count($users)) ); + notice( sprintf( tt("%s user blocked/unblocked", "%s users blocked/unblocked", count($users)), count($users)) ); } if (x($_POST,'page_users_delete')){ require_once("include/Contact.php"); @@ -428,6 +428,7 @@ function admin_page_users(&$a){ LEFT JOIN `contact` ON `register`.`uid` = `contact`.`uid` LEFT JOIN `user` ON `register`.`uid` = `user`.`uid`;"); + /* get users */ $total = q("SELECT count(*) as total FROM `user` where 1"); @@ -435,7 +436,8 @@ function admin_page_users(&$a){ $a->set_pager_total($total[0]['total']); $a->set_pager_itemspage(100); } - + + $users = q("SELECT `user` . * , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date` FROM (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid` @@ -469,6 +471,7 @@ function admin_page_users(&$a){ } $users = array_map("_setup_users", $users); + $t = get_markup_template("admin_users.tpl"); $o = replace_macros($t, array( // strings // diff --git a/mod/contacts.php b/mod/contacts.php index ce352fe204..c99ac14520 100755 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -505,6 +505,7 @@ function contacts_content(&$a) { 'username' => $rr['name'], 'sparkle' => $sparkle, 'itemurl' => $rr['url'], + 'url' => $url, 'network' => network_to_name($rr['network']), ); } diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index 5a24f00893..0bc3ea7df5 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -107,7 +107,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { * */ - $r = q("SELECT * FROM `contact` WHERE ( ( `issued-id` != '' AND `issued-id` = '%s' ) OR ( `id` = %d AND `id` != 0 ) ) AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE ( ( `issued-id` != '' AND `issued-id` = '%s' ) OR ( `id` = %d AND `id` != 0 ) ) AND `uid` = %d AND `duplex` = 0 LIMIT 1", dbesc($dfrn_id), intval($cid), intval($uid) @@ -116,6 +116,7 @@ function dfrn_confirm_post(&$a,$handsfree = null) { if(! count($r)) { logger('dfrn_confirm: Contact not found in DB.'); notice( t('Contact not found.') . EOL ); + notice( t('This may occasionally happen if contact was requested by both persons and it has already been approved.') . EOL ); return; } @@ -631,6 +632,15 @@ function dfrn_confirm_post(&$a,$handsfree = null) { xml_status(3,$message); } + // It's possible that the other person also requested friendship. + // If it is a duplex relationship, ditch the issued-id if one exists. + + if($duplex) { + $r = q("UPDATE `contact` SET `issued-id` = '' WHERE `id` = %d LIMIT 1", + intval($dfrn_record) + ); + } + // We're good but now we have to scrape the profile photo and send notifications. diff --git a/mod/display.php b/mod/display.php index d96be4333b..f510f793df 100755 --- a/mod/display.php +++ b/mod/display.php @@ -74,11 +74,11 @@ function display_content(&$a) { $x = array( 'is_owner' => true, 'allow_location' => $a->user['allow_location'], - 'default_location' => $a->user['default_location'], + 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], - 'lockstate' => ((($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'), - 'acl' => populate_acl((($group || $cid) ? $def_acl : $a->user), $celeb), - 'bang' => (($group || $cid) ? '!' : ''), + 'lockstate' => ( (is_array($a->user)) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))) ? 'lock' : 'unlock'), + 'acl' => populate_acl($a->user, $celeb), + 'bang' => '', 'visitor' => 'block', 'profile_uid' => local_user() ); diff --git a/mod/group.php b/mod/group.php index c896362ca2..f6f8e41733 100755 --- a/mod/group.php +++ b/mod/group.php @@ -76,14 +76,17 @@ function group_content(&$a) { if($switchtotext === false) $switchtotext = 400; + $tpl = get_markup_template('group_edit.tpl'); + $context = array('$submit' => t('Submit')); + if(($a->argc == 2) && ($a->argv[1] === 'new')) { - $tpl = get_markup_template('group_new.tpl'); - $o .= replace_macros($tpl,array( - '$desc' => t('Create a group of contacts/friends.'), - '$name' => t('Group Name: '), - '$submit' => t('Submit') - )); - return $o; + + return replace_macros($tpl, $context + array( + '$title' => t('Create a group of contacts/friends.'), + '$gname' => array('groupname',t('Group Name: '),$group['name'], ''), + )); + + } if(($a->argc == 3) && ($a->argv[1] === 'drop')) { @@ -156,66 +159,61 @@ function group_content(&$a) { $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); - $tpl = get_markup_template('group_edit.tpl'); - $o .= replace_macros($tpl, array( - '$gid' => $group['id'], - '$name' => $group['name'], - '$drop' => $drop_txt, - '$desc' => t('Click on a contact to add or remove.'), + + $context = $context + array( '$title' => t('Group Editor'), - '$gname' => t('Group Name: '), - '$submit' => t('Submit') - )); + '$gname' => array('groupname',t('Group Name: '),$group['name'], ''), + '$gid' => $group['id'], + '$drop' => $drop_txt, + ); } if(! isset($group)) return; - $o .= '
'; - if($change) - $o = ''; + $groupeditor = array( + 'label_members' => t('Members'), + 'members' => array(), + 'label_contacts' => t('All Contacts'), + 'contacts' => arraY(), + ); + - $o .= '

' . t('Members') . '

'; - $o .= '
'; $textmode = (($switchtotext && (count($members) > $switchtotext)) ? true : false); foreach($members as $member) { if($member['url']) { $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . '); return true;'; - $o .= micropro($member,true,'mpgroup', $textmode); + $groupeditor['members'][] = micropro($member,true,'mpgroup', $textmode); } else group_rmv_member(local_user(),$group['name'],$member['id']); } - $o .= '
'; - $o .= '
'; - - $o .= '

' . t('All Contacts') . '

'; - $o .= '
'; + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0 ORDER BY `name` ASC", + intval(local_user()) + ); - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 and `pending` = 0 and `self` = 0 ORDER BY `name` ASC", - intval(local_user()) - ); - - if(count($r)) { - $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); - foreach($r as $member) { - if(! in_array($member['id'],$preselected)) { - $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . '); return true;'; - $o .= micropro($member,true,'mpall', $textmode); - } + if(count($r)) { + $textmode = (($switchtotext && (count($r) > $switchtotext)) ? true : false); + foreach($r as $member) { + if(! in_array($member['id'],$preselected)) { + $member['click'] = 'groupChangeMember(' . $group['id'] . ',' . $member['id'] . '); return true;'; + $groupeditor['contacts'][] = micropro($member,true,'mpall', $textmode); } } + } - $o .= '
'; + $context['$groupeditor'] = $groupeditor; + $context['$desc'] = t('Click on a contact to add or remove.'); if($change) { - echo $o; + $tpl = get_markup_template('groupeditor.tpl'); + echo replace_macros($tpl, $context); killme(); } - $o .= '
'; - return $o; + + return replace_macros($tpl, $context); } diff --git a/mod/network.php b/mod/network.php index 03a671b615..894ac48ed6 100755 --- a/mod/network.php +++ b/mod/network.php @@ -263,7 +263,7 @@ function network_content(&$a, $update = 0) { $x = array( 'is_owner' => true, 'allow_location' => $a->user['allow_location'], - 'default_location' => $a->user['default_location'], + 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => ((($group) || (is_array($a->user) && ((strlen($a->user['allow_cid'])) || (strlen($a->user['allow_gid'])) || (strlen($a->user['deny_cid'])) || (strlen($a->user['deny_gid']))))) ? 'lock' : 'unlock'), 'acl' => populate_acl((($group || $cid) ? $def_acl : $a->user), $celeb), diff --git a/mod/notify.php b/mod/notify.php index e6a7a88596..a572b15344 100644 --- a/mod/notify.php +++ b/mod/notify.php @@ -11,8 +11,10 @@ function notify_init(&$a) { intval(local_user()) ); if(count($r)) { - q("update notify set seen = 1 where id = %d and uid = %d limit 1", - intval($a->argv[2]), + q("update notify set seen = 1 where ( link = '%s' or ( parent != 0 and parent = %d and otype = '%s' )) and uid = %d", + dbesc($r[0]['link']), + intval($r[0]['parent']), + dbesc($r[0]['otype']), intval(local_user()) ); goaway($r[0]['link']); diff --git a/mod/ping.php b/mod/ping.php index 7380ff7d05..1562254b17 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -14,10 +14,29 @@ function ping_init(&$a) { $firehose = intval(get_pconfig(local_user(),'system','notify_full')); - $z = q("select * from notify where uid = %d - order by seen asc, date desc limit 0, 50", + $t = q("select count(*) as total from notify where uid = %d and seen = 0", intval(local_user()) ); + if($t && intval($t[0]['total']) > 49) { + $z = q("select * from notify where uid = %d + and seen = 0 order by date desc limit 0, 50", + intval(local_user()) + ); + } + else { + $z1 = q("select * from notify where uid = %d + and seen = 0 order by date desc limit 0, 50", + intval(local_user()) + ); + + $z2 = q("select * from notify where uid = %d + and seen = 1 order by date desc limit 0, %d", + intval(local_user()), + intval(50 - intval($t[0]['total'])) + ); + $z = array_merge($z1,$z2); + } + $tags = array(); diff --git a/mod/settings.php b/mod/settings.php index 90eb9dbd78..a9d00bc981 100755 --- a/mod/settings.php +++ b/mod/settings.php @@ -50,6 +50,8 @@ function settings_post(&$a) { return; } + $old_page_flags = $a->user['page-flags']; + if(($a->argc > 1) && ($a->argv[1] === 'oauth') && x($_POST,'remove')){ $key = $_POST['remove']; q("DELETE FROM tokens WHERE id='%s' AND uid=%d", @@ -375,7 +377,7 @@ function settings_post(&$a) { ); } - if($old_visibility != $net_publish) { + if(($old_visibility != $net_publish) || ($page_flags != $old_page_flags)) { // Update global directory in background $url = $_SESSION['my_url']; if($url && strlen(get_config('system','directory_submit_url'))) diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 10c980d93b..6b66f60d77 100755 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -63,7 +63,8 @@ function viewcontacts_content(&$a) { 'username' => $rr['name'], 'url' => $url, 'sparkle' => '', - 'item' => $rr, + 'itemurl' => $rr['url'], + 'network' => network_to_name($rr['network']), ); } diff --git a/update.php b/update.php index 865c6175e9..c29394b480 100755 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@
$contact.name
+ {{ if $contact.alt_text }}
$contact.alt_text
{{ endif }}
$contact.itemurl
$contact.network
diff --git a/view/conversation.tpl b/view/conversation.tpl index 7d4e7d2621..ff202bbe44 100755 --- a/view/conversation.tpl +++ b/view/conversation.tpl @@ -1,6 +1,18 @@ {{ for $threads as $thread }}
- $thread.html + {{ for $thread.items as $item }} + {{if $item.comment_firstcollapsed}} +
+ $thread.num_comments $thread.hide_text +
+ {{endif}} + + {{ inc $item.template }}{{ endinc }} + + + {{ endfor }}
{{ endfor }} diff --git a/view/group_edit.tpl b/view/group_edit.tpl index 51782ab952..3689db7535 100755 --- a/view/group_edit.tpl +++ b/view/group_edit.tpl @@ -2,17 +2,21 @@
-
-
- - -
-
-$drop -
- -
-
$desc
-
-
+
+ + {{ inc field_input.tpl with $field=$gname }}{{ endinc }} + {{ if $drop }}$drop{{ endif }} +
+ +
+
+
+ + +{{ if $groupeditor }} +
+ {{ inc groupeditor.tpl }}{{ endinc }} +
+{{ endif }} +{{ if $desc }}
$desc
{{ endif }} diff --git a/view/group_new.tpl b/view/group_new.tpl deleted file mode 100755 index 735b51634d..0000000000 --- a/view/group_new.tpl +++ /dev/null @@ -1,23 +0,0 @@ - - - -
-
- -
-

-$desc - -

- - -
-
- -
- - -
-
- - \ No newline at end of file diff --git a/view/groupeditor.tpl b/view/groupeditor.tpl new file mode 100644 index 0000000000..755985eb35 --- /dev/null +++ b/view/groupeditor.tpl @@ -0,0 +1,16 @@ +
+

$groupeditor.label_members

+
+{{ for $groupeditor.members as $c}} $c {{ endfor }} +
+
+
+
+ +
+

$groupeditor.label_contacts

+
+{{ for $groupeditor.contacts as $m}} $m {{ endfor }} +
+
+
diff --git a/view/search_item.tpl b/view/search_item.tpl index de8bd23961..a889062e06 100755 --- a/view/search_item.tpl +++ b/view/search_item.tpl @@ -1,75 +1,75 @@
- $star.starred - {{ if $lock }}$lock{{ endif }} - + $item.star.starred + {{ if $item.lock }}$item.lock{{ endif }} +
-
+
- {{ for $tags as $tag }} - $tag + {{ for $item.tags as $item.tag }} + $item.tag {{ endfor }}
- {{ if $plink }}$plink.title{{ endif }} + {{ if $item.plink }}$item.plink.title{{ endif }}
- $name $ago + $item.name $item.ago
- {{ if $star }} - $star.do - $star.undo - $star.tagger + {{ if $item.star }} + $item.star.do + $item.star.undo + $item.star.tagger {{ endif }} - {{ if $vote }} - $vote.like.1 - $vote.dislike.1 + {{ if $item.vote }} + $item.vote.like.1 + $item.vote.dislike.1 {{ endif }} - {{ if $vote.share }} - $vote.share.1 + {{ if $item.vote.share }} + $item.vote.share.1 {{ endif }}
- {{ if $drop.dropping }} - - $drop.delete + {{ if $item.drop.dropping }} + + $item.drop.delete {{ endif }} - {{ if $edpost }} - + {{ if $item.edpost }} + {{ endif }}
@@ -77,11 +77,11 @@
- -
$dislike
- {{ if $conv }} -
- $conv.title + +
$item.dislike
+ {{ if $item.conv }} +
+ $item.conv.title {{ endif }}
diff --git a/view/theme/diabook b/view/theme/diabook new file mode 160000 index 0000000000..e29c43c4e7 --- /dev/null +++ b/view/theme/diabook @@ -0,0 +1 @@ +Subproject commit e29c43c4e78e42f448cbd84dc51a3a346bdab01f diff --git a/view/theme/dispy/search_item.tpl b/view/theme/dispy/search_item.tpl index 3d841ab080..54c3e389c0 100755 --- a/view/theme/dispy/search_item.tpl +++ b/view/theme/dispy/search_item.tpl @@ -1,40 +1,40 @@ -
-
-
-
- - $name - menu -
+
+
+
+
+ + $item.name + menu +
    - $item_photo_menu + $item.item_photo_menu
-
{{ if $location }}$location {{ endif }}
+
{{ if $item.location }}$item.location {{ endif }}
- {{ if $lock }}
$lock
+ {{ if $item.lock }}
$item.lock
{{ else }}
{{ endif }}
-
-
- {{ if $drop.dropping }}{{ endif }} +
+
+ {{ if $item.drop.dropping }}{{ endif }}
- {{ if $drop.dropping }}{{ endif }} + {{ if $item.drop.dropping }}{{ endif }}
-
-
$title
+
+
$item.title
-
$body
+
$item.body
- $name -
$ago
+ $item.name +
$item.ago
@@ -42,10 +42,10 @@
-
-
- {{ if $conv }} - $conv.title +
+
+ {{ if $item.conv }} + $item.conv.title {{ endif }}
diff --git a/view/theme/dispy/wall_item.tpl b/view/theme/dispy/wall_item.tpl index 882843a093..0dcd30f7b4 100755 --- a/view/theme/dispy/wall_item.tpl +++ b/view/theme/dispy/wall_item.tpl @@ -1,77 +1,77 @@ -
-
-
-
- - $name +
+
+
+
+ + $item.name - menu -
+ menu +
    - $item_photo_menu + $item.item_photo_menu
-
{{ if $location }}$location {{ endif }}
+
{{ if $item.location }}$item.location {{ endif }}
- {{ if $lock }}
$lock
+ {{ if $item.lock }}
$item.lock
{{ else }}
{{ endif }}
-
- {{ if $star }} - - +
+ {{ if $item.star }} + + {{ endif }} - {{ if $vote }} -