diff options
author | Fabio Comuni <fabrix.xm@gmail.com> | 2011-09-05 09:09:34 +0200 |
---|---|---|
committer | Fabio Comuni <fabrix.xm@gmail.com> | 2011-09-05 09:09:34 +0200 |
commit | 0283cbfcd35a29b5689ffbf16439d448de0c7254 (patch) | |
tree | 9fa9aa4b7fb3454ab60d63ad584aafaf20850999 /include | |
parent | 058e329dfbc2678fa7e3cb2ce130fb9ffd69b84d (diff) | |
parent | 7e8100d2cd27227435ba6ff421dd3c3d8689930f (diff) | |
download | volse-hubzilla-0283cbfcd35a29b5689ffbf16439d448de0c7254.tar.gz volse-hubzilla-0283cbfcd35a29b5689ffbf16439d448de0c7254.tar.bz2 volse-hubzilla-0283cbfcd35a29b5689ffbf16439d448de0c7254.zip |
Merge remote-tracking branch 'friendika/master' into newui
Diffstat (limited to 'include')
-rw-r--r-- | include/Scrape.php | 16 | ||||
-rw-r--r-- | include/bb2diaspora.php | 66 | ||||
-rw-r--r-- | include/bbcode.php | 84 | ||||
-rw-r--r-- | include/conversation.php | 2 | ||||
-rw-r--r-- | include/crypto.php | 15 | ||||
-rw-r--r-- | include/delivery.php | 5 | ||||
-rw-r--r-- | include/diaspora.php | 31 | ||||
-rw-r--r-- | include/group.php | 6 | ||||
-rw-r--r-- | include/items.php | 9 | ||||
-rw-r--r-- | include/notifier.php | 20 | ||||
-rw-r--r-- | include/text.php | 4 |
11 files changed, 185 insertions, 73 deletions
diff --git a/include/Scrape.php b/include/Scrape.php index cc46af644..bf64c2243 100644 --- a/include/Scrape.php +++ b/include/Scrape.php @@ -332,10 +332,12 @@ function probe_url($url, $mode = PROBE_NORMAL) { if(! $url) return $result; + $network = null; $diaspora = false; $diaspora_base = ''; $diaspora_guid = ''; $diaspora_key = ''; + $has_lrdd = false; $email_conversant = false; $twitter = ((strpos($url,'twitter.com') !== false) ? true : false); @@ -352,6 +354,8 @@ function probe_url($url, $mode = PROBE_NORMAL) { $links = lrdd($url); if(count($links)) { + $has_lrdd = true; + logger('probe_url: found lrdd links: ' . print_r($links,true), LOGGER_DATA); foreach($links as $link) { if($link['@attributes']['rel'] === NAMESPACE_ZOT) @@ -493,7 +497,7 @@ function probe_url($url, $mode = PROBE_NORMAL) { if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) { if($diaspora) $network = NETWORK_DIASPORA; - else + elseif($has_lrdd) $network = NETWORK_OSTATUS; $priority = 0; @@ -637,7 +641,7 @@ function probe_url($url, $mode = PROBE_NORMAL) { $vcard['nick'] = trim(substr($vcard['nick'],0,strpos($vcard['nick'],' '))); } if(! $network) - $network = 'feed'; + $network = NETWORK_FEED; if(! $priority) $priority = 2; } @@ -651,10 +655,14 @@ function probe_url($url, $mode = PROBE_NORMAL) { if(! $profile) $profile = $url; - $vcard['fn'] = notags($vcard['fn']); - $vcard['nick'] = str_replace(' ','',notags($vcard['nick'])); + // No human could be associated with this link, use the URL as the contact name + if(($network === NETWORK_FEED) && ($poll) && (! x($vcard,'fn'))) + $vcard['fn'] = $url; + $vcard['fn'] = notags($vcard['fn']); + $vcard['nick'] = str_replace(' ','',notags($vcard['nick'])); + $result['name'] = $vcard['fn']; $result['nick'] = $vcard['nick']; $result['url'] = $profile; diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 7f7b8748d..ca0c961b3 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -16,7 +16,10 @@ function diaspora2bb($s) { $s = preg_replace("/\*(.+?)\*/", '[i]$1[/i]', $s); $s = preg_replace("/\_(.+?)\_/", '[i]$1[/i]', $s); $s = str_replace(array('-^doublestar^-','-^doublescore-^','-^star^-','-^score^-'), array('**','__','*','_'), $s); + $s = preg_replace('/\!\[(.+?)\]\((.+?)\)/','[img]$2[/img]',$s); $s = preg_replace('/\[(.+?)\]\((.+?)\)/','[url=$2]$1[/url]',$s); + $s = preg_replace('/\@\{(.+?)\; (.+?)\@(.+?)\}/','@[url=https://$3/u/$2]$1[/url]',$s); + $s = escape_tags($s); return $s; @@ -40,6 +43,11 @@ function bb2diaspora($Text,$preserve_nl = false) { $Text = str_replace("<", "<", $Text); $Text = str_replace(">", ">", $Text); + // If we find any event code, turn it into an event. + // After we're finished processing the bbcode we'll + // replace all of the event code with a reformatted version. + + $ev = bbtoevent($Text); if($preserve_nl) $Text = str_replace(array("\n","\r"), array('',''),$Text); @@ -54,8 +62,9 @@ function bb2diaspora($Text,$preserve_nl = false) { // [img]pathtoimage[/img] - $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '[$1]($1)', $Text); - $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.*?)\[/url\])", '[$2]($1)', $Text); + $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '[$1]($1)', $Text); + $Text = preg_replace("/\#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[#$2]($1)', $Text); + $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '[$2]($1)', $Text); // $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('Image/photo: ') . '$1', $Text); // $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('image/photo'), $Text); @@ -156,19 +165,20 @@ function bb2diaspora($Text,$preserve_nl = false) { // oembed tag -// $Text = oembed_bbcode2html($Text); + // $Text = oembed_bbcode2html($Text); // If we found an event earlier, strip out all the event code and replace with a reformatted version. -// if(x($ev,'desc') && x($ev,'start')) { -// $sub = format_event_html($ev); + if(x($ev,'desc') && x($ev,'start')) { - // $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text); - //$Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text); -// $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text); -// $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text); -// $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text); -// } + $sub = format_event_diaspora($ev); + + $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text); + $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text); + $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text); + $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text); + $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text); + } @@ -176,3 +186,37 @@ function bb2diaspora($Text,$preserve_nl = false) { return $Text; } + +function format_event_diaspora($ev) { + + if(! ((is_array($ev)) && count($ev))) + return ''; + + $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM + + $o = 'Friendika event notification:' . "\n"; + + $o .= '**' . bb2diaspora($ev['desc']) . '**' . "\n"; + + $o .= t('Starts:') . ' ' + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC', + $ev['start'] , $bd_format )) + : day_translate(datetime_convert('UTC', 'UTC', + $ev['start'] , $bd_format))) + . "\n"; + + if(! $ev['nofinish']) + $o .= t('Finishes:') . ' ' + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', 'UTC', + $ev['finish'] , $bd_format )) + : day_translate(datetime_convert('UTC', 'UTC', + $ev['finish'] , $bd_format ))) + . "\n"; + + if(strlen($ev['location'])) + $o .= t('Location:') . bb2diaspora($ev['location']) + . "\n"; + + $o .= "\n"; + return $o; +} diff --git a/include/bbcode.php b/include/bbcode.php index a3f2971e5..86b7fdb4b 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -43,65 +43,65 @@ function bbcode($Text,$preserve_nl = false) { $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\%\$\!\+\,]+)/", '$1<a href="$2" target="external-link">$2</a>', $Text); - $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" target="external-link">$1</a>', $Text); - $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.*?)\[/url\])", '<a href="$1" target="external-link">$2</a>', $Text); - //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text); + $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/m", '<a href="$1" target="external-link">$1</a>', $Text); + $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/m", '<a href="$1" target="external-link">$2</a>', $Text); + //$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/m", '<a href="$1" target="_blank">$2</a>', $Text); // Perform MAIL Search - $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text); + $Text = preg_replace("/\[mail\]([$MAILSearchString]*)\[\/mail\]/", '<a href="mailto:$1">$1</a>', $Text); $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text); // Check for bold text - $Text = preg_replace("(\[b\](.*?)\[\/b\])is",'<strong>$1</strong>',$Text); + $Text = preg_replace("(\[b\](.*?)\[\/b\])ism",'<strong>$1</strong>',$Text); // Check for Italics text - $Text = preg_replace("(\[i\](.*?)\[\/i\])is",'<em>$1</em>',$Text); + $Text = preg_replace("(\[i\](.*?)\[\/i\])ism",'<em>$1</em>',$Text); // Check for Underline text - $Text = preg_replace("(\[u\](.*?)\[\/u\])is",'<u>$1</u>',$Text); + $Text = preg_replace("(\[u\](.*?)\[\/u\])ism",'<u>$1</u>',$Text); // Check for strike-through text - $Text = preg_replace("(\[s\](.*?)\[\/s\])is",'<strike>$1</strike>',$Text); + $Text = preg_replace("(\[s\](.*?)\[\/s\])ism",'<strike>$1</strike>',$Text); // Check for over-line text - $Text = preg_replace("(\[o\](.*?)\[\/o\])is",'<span class="overline">$1</span>',$Text); + $Text = preg_replace("(\[o\](.*?)\[\/o\])ism",'<span class="overline">$1</span>',$Text); // Check for colored text - $Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])is","<span style=\"color: $1;\">$2</span>",$Text); + $Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])ism","<span style=\"color: $1;\">$2</span>",$Text); // Check for sized text - $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])is","<span style=\"font-size: $1;\">$2</span>",$Text); + $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])ism","<span style=\"font-size: $1;\">$2</span>",$Text); // Check for list text - $Text = preg_replace("/\[list\](.*?)\[\/list\]/is", '<ul class="listbullet">$1</ul>' ,$Text); - $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/is", '<ul class="listdecimal">$1</ul>' ,$Text); - $Text = preg_replace("/\[list=i\](.*?)\[\/list\]/s",'<ul class="listlowerroman">$1</ul>' ,$Text); - $Text = preg_replace("/\[list=I\](.*?)\[\/list\]/s", '<ul class="listupperroman">$1</ul>' ,$Text); - $Text = preg_replace("/\[list=a\](.*?)\[\/list\]/s", '<ul class="listloweralpha">$1</ul>' ,$Text); - $Text = preg_replace("/\[list=A\](.*?)\[\/list\]/s", '<ul class="listupperalpha">$1</ul>' ,$Text); - $Text = preg_replace("/\[li\](.*?)\[\/li\]/s", '<li>$1</li>' ,$Text); + $Text = preg_replace("/\[list\](.*?)\[\/list\]/ism", '<ul class="listbullet">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/ism", '<ul class="listdecimal">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=i\](.*?)\[\/list\]/sm",'<ul class="listlowerroman">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=I\](.*?)\[\/list\]/sm", '<ul class="listupperroman">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=a\](.*?)\[\/list\]/sm", '<ul class="listloweralpha">$1</ul>' ,$Text); + $Text = preg_replace("/\[list=A\](.*?)\[\/list\]/sm", '<ul class="listupperalpha">$1</ul>' ,$Text); + $Text = preg_replace("/\[li\](.*?)\[\/li\]/sm", '<li>$1</li>' ,$Text); - $Text = preg_replace("/\[td\](.*?)\[\/td\]/s", '<td>$1</td>' ,$Text); - $Text = preg_replace("/\[tr\](.*?)\[\/tr\]/s", '<tr>$1</tr>' ,$Text); - $Text = preg_replace("/\[table\](.*?)\[\/table\]/s", '<table>$1</table>' ,$Text); + $Text = preg_replace("/\[td\](.*?)\[\/td\]/sm", '<td>$1</td>' ,$Text); + $Text = preg_replace("/\[tr\](.*?)\[\/tr\]/sm", '<tr>$1</tr>' ,$Text); + $Text = preg_replace("/\[table\](.*?)\[\/table\]/sm", '<table>$1</table>' ,$Text); - $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/s", '<table border="1" >$1</table>' ,$Text); - $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/s", '<table border="0" >$1</table>' ,$Text); + $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/sm", '<table border="1" >$1</table>' ,$Text); + $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/sm", '<table border="0" >$1</table>' ,$Text); // $Text = str_replace("[*]", "<li>", $Text); // Check for font change text - $Text = preg_replace("(\[font=(.*?)\](.*?)\[\/font\])","<span style=\"font-family: $1;\">$2</span>",$Text); + $Text = preg_replace("/\[font=(.*?)\](.*?)\[\/font\]/m","<span style=\"font-family: $1;\">$2</span>",$Text); // Declare the format for [code] layout - $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/is",'stripcode_br_cb',$Text); + $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism",'stripcode_br_cb',$Text); $CodeLayout = '<code>$1</code>'; // Check for [code] text - $Text = preg_replace("/\[code\](.*?)\[\/code\]/is","$CodeLayout", $Text); + $Text = preg_replace("/\[code\](.*?)\[\/code\]/ism","$CodeLayout", $Text); @@ -109,22 +109,22 @@ function bbcode($Text,$preserve_nl = false) { // Declare the format for [quote] layout $QuoteLayout = '<blockquote>$1</blockquote>'; // Check for [quote] text - $Text = preg_replace("/\[quote\](.*?)\[\/quote\]/is","$QuoteLayout", $Text); + $Text = preg_replace("/\[quote\](.*?)\[\/quote\]/ism","$QuoteLayout", $Text); // Images // [img]pathtoimage[/img] - $Text = preg_replace("/\[img\](.*?)\[\/img\]/", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text); + $Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $Text); // html5 video and audio - $Text = preg_replace("/\[video\](.*?)\[\/video\]/", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text); + $Text = preg_replace("/\[video\](.*?)\[\/video\]/ism", '<video src="$1" controls="controls" width="425" height="350"><a href="$1">$1</a></video>', $Text); - $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text); + $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/ism", '<audio src="$1" controls="controls"><a href="$1">$1</a></audio>', $Text); - $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text); + $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/ism", '<iframe src="$1" width="425" height="350"><a href="$1">$1</a></iframe>', $Text); // [img=widthxheight]image source[/img] - $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/", '<img src="$3" style="height:{$2}px; width:{$1}px;" >', $Text); + $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '<img src="$3" style="height:{$2}px; width:{$1}px;" >', $Text); if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){ // use oembed for youtube links @@ -132,13 +132,15 @@ function bbcode($Text,$preserve_nl = false) { $Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text); } else { // Youtube extensions - $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); - $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text); - $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<iframe width="425" height="349" src="http://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text); + $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); + $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/embed\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); + $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/ism",'[youtube]$1[/youtube]',$Text); + $Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="425" height="350" src="http://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text); } -// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text); +// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text); + // oembed tag $Text = oembed_bbcode2html($Text); @@ -148,11 +150,11 @@ function bbcode($Text,$preserve_nl = false) { if(x($ev,'desc') && x($ev,'start')) { $sub = format_event_html($ev); - $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text); - $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text); - $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text); - $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text); - $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text); + $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",$sub,$Text); + $Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/ism",'',$Text); + $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text); + $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text); + $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text); } diff --git a/include/conversation.php b/include/conversation.php index 3353cb2b7..6b5bf8d7c 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -80,8 +80,6 @@ function localize_item(&$item){ } - // fix bad embeds - $item['body'] = str_replace('http://www.youtube.com/embed/http:','http:',$item['body']); } diff --git a/include/crypto.php b/include/crypto.php index 88e05b9eb..0feb45c24 100644 --- a/include/crypto.php +++ b/include/crypto.php @@ -262,24 +262,27 @@ function aes_unencapsulate($data,$prvkey) { } -function zot_encapsulate($data,$sender,$pubkey) { +// This has been superceded. + +function zot_encapsulate($data,$envelope,$pubkey) { $res = aes_encapsulate($data,$pubkey); -openssl_public_encrypt($sender,$s,$pubkey); -$s1 = base64url_encode($s,true); return <<< EOT <?xml version='1.0' encoding='UTF-8'?> -<zot:env xmlns:zot='http://purl.org/zot/1.0'> +<zot:msg xmlns:zot='http://purl.org/zot/1.0'> <zot:key>{$res['key']}</zot:key> <zot:iv>{$res['iv']}</zot:iv> - <zot:sender>$s1</zot:sender> + <zot:env>$s1</zot:env> + <zot:sig key_id="$keyid">$sig</zot:sig> <zot:alg>AES-256-CBC</zot:alg> <zot:data type='application/magic-envelope+xml'>{$res['data']}</zot:data> -</zot:env> +</zot:msg> EOT; } +// so has this + function zot_unencapsulate($data,$prvkey) { $ret = array(); $c = array(); diff --git a/include/delivery.php b/include/delivery.php index 5d81228ee..18ef09a31 100644 --- a/include/delivery.php +++ b/include/delivery.php @@ -140,6 +140,8 @@ function delivery_run($argv, $argc){ $owner = $r[0]; + $walltowall = ((($top_level) && ($owner['id'] != $items[0]['contact-id'])) ? true : false); + $public_message = true; // fill this in with a single salmon slap if applicable @@ -417,7 +419,8 @@ function delivery_run($argv, $argc){ diaspora_send_relay($target_item,$owner,$contact); break; } - elseif($top_level) { + elseif(($top_level) && (! $walltowall)) { + // currently no workable solution for sending walltowall logger('delivery: diaspora status: ' . $contact['name']); diaspora_send_status($target_item,$owner,$contact); break; diff --git a/include/diaspora.php b/include/diaspora.php index fc9289039..6d070ecba 100644 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -398,6 +398,7 @@ function diaspora_request($importer,$xml) { function diaspora_post($importer,$xml) { + $a = get_app(); $guid = notags(unxmlify($xml->guid)); $diaspora_handle = notags(unxmlify($xml->diaspora_handle)); @@ -457,7 +458,14 @@ function diaspora_post($importer,$xml) { $datarray['body'] = $body; $datarray['app'] = 'Diaspora'; - item_store($datarray); + $message_id = item_store($datarray); + + if($message_id) { + q("update item set plink = '%s' where id = %d limit 1", + dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), + intval($message_id) + ); + } return; @@ -465,6 +473,7 @@ function diaspora_post($importer,$xml) { function diaspora_comment($importer,$xml,$msg) { + $a = get_app(); $guid = notags(unxmlify($xml->guid)); $parent_guid = notags(unxmlify($xml->parent_guid)); $diaspora_handle = notags(unxmlify($xml->diaspora_handle)); @@ -576,6 +585,13 @@ function diaspora_comment($importer,$xml,$msg) { $message_id = item_store($datarray); + if($message_id) { + q("update item set plink = '%s' where id = %d limit 1", + dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), + intval($message_id) + ); + } + if(! $parent_author_signature) { q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", intval($message_id), @@ -595,6 +611,7 @@ function diaspora_comment($importer,$xml,$msg) { function diaspora_photo($importer,$xml,$msg) { + $a = get_app(); $remote_photo_path = notags(unxmlify($xml->remote_photo_path)); $remote_photo_name = notags(unxmlify($xml->remote_photo_name)); @@ -732,8 +749,8 @@ function diaspora_like($importer,$xml,$msg) { } if($parent_author_signature) { -// $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $msg['author']; - $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $diaspora_handle; + + $owner_signed_data = $guid . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $diaspora_handle; $parent_author_signature = base64_decode($parent_author_signature); @@ -805,6 +822,14 @@ EOT; $message_id = item_store($arr); + + if($message_id) { + q("update item set plink = '%s' where id = %d limit 1", + dbesc($a->get_baseurl() . '/display/' . $importer['nickname'] . '/' . $message_id), + intval($message_id) + ); + } + if(! $parent_author_signature) { q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", intval($message_id), diff --git a/include/group.php b/include/group.php index f21ce42e0..8798adf5a 100644 --- a/include/group.php +++ b/include/group.php @@ -154,7 +154,7 @@ $o .= <<< EOT <div id="sidebar-group-list"> <ul id="sidebar-group-ul"> - <li class="sidebar-group-li" ><a href="$every" $selected >$linktext</a></li> + <li class="sidebar-group-li" ><a href="$every" class="sidebar-group-element" $selected >$linktext</a></li> EOT; @@ -170,10 +170,10 @@ EOT; $selected = (($group_id == $rr['id']) ? ' class="group-selected" ' : ''); $o .= ' <li class="sidebar-group-li">' . (($edit) ? "<a href=\"group/{$rr['id']}\" title=\"" . t('Edit') - . "\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "") + . "\" class=\"groupsideedit\" ><img src=\"images/spencil.gif\" alt=\"" . t('Edit') . "\"></a> " : "") . (($cid) ? '<input type="checkbox" class="' . (($selected) ? 'ticked' : 'unticked') . '" onclick="contactgroupChangeMember(' . $rr['id'] . ',' . $cid . ');return true;" ' . ((in_array($rr['id'],$member_of)) ? ' checked="checked" ' : '') . '/>' : '') - . "<a href=\"$each/{$rr['id']}\" $selected >{$rr['name']}</a></li>\r\n"; + . "<a href=\"$each/{$rr['id']}\" class=\"sidebar-group-element\" $selected >{$rr['name']}</a></li>\r\n"; } } $o .= " </ul>\r\n </div>"; diff --git a/include/items.php b/include/items.php index 1603dec60..facd8b2d4 100644 --- a/include/items.php +++ b/include/items.php @@ -20,6 +20,8 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) for($x = 2; $x < $a->argc; $x++) { if($a->argv[$x] == 'converse') $converse = true; + if($a->argv[$x] == 'starred') + $starred = true; } } @@ -376,6 +378,10 @@ function get_atom_elements($feed,$item) { if($dguid) $res['guid'] = unxmlify($dguid[0]['data']); + $bm = $item->get_item_tags(NAMESPACE_DFRN,'bookmark'); + if($bm) + $res['bookmark'] = ((unxmlify($bm[0]['data']) === 'true') ? 1 : 0); + /** * If there's a copy of the body content which is guaranteed to have survived mangling in transit, use it. @@ -731,6 +737,7 @@ function item_store($arr,$force_parent = false) { $arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : ''); $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : ''); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0 ); + $arr['bookmark'] = ((x($arr,'bookmark')) ? intval($arr['bookmark']) : 0 ); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); $arr['tag'] = ((x($arr,'tag')) ? notags(trim($arr['tag'])) : ''); $arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : ''); @@ -1704,6 +1711,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { if($item['extid']) $o .= '<dfrn:extid>' . xmlify($item['extid']) . '</dfrn:extid>' . "\r\n"; + if($item['bookmark']) + $o .= '<dfrn:bookmark>true</dfrn:bookmark>' . "\r\n"; if($item['app']) $o .= '<statusnet:notice_info local_id="' . $item['id'] . '" source="' . xmlify($item['app']) . '" ></statusnet:notice_info>' . "\r\n"; diff --git a/include/notifier.php b/include/notifier.php index 8d2aa961c..6ac882c19 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -2,6 +2,20 @@ require_once("boot.php"); +/* + * This file was at one time responsible for doing all deliveries, but this caused + * big problems on shared hosting systems, where the process might get killed by the + * hosting provider and nothing would get delivered. + * It now only delivers one message under certain cases, and invokes a queued + * delivery mechanism (include/deliver.php) to deliver individual contacts at + * controlled intervals. + * This has a much better chance of surviving random processes getting killed + * by the hosting provider. + * A lot of this code is duplicated in include/deliver.php until we have time to go back + * and re-structure the delivery procedure based on the obstacles that have been thrown at + * us by hosting providers. + */ + function notifier_run($argv, $argc){ global $a, $db; @@ -129,6 +143,7 @@ function notifier_run($argv, $argc){ logger('notifier: top level post'); $top_level = true; } + } $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, @@ -144,6 +159,8 @@ function notifier_run($argv, $argc){ $owner = $r[0]; + $walltowall = ((($top_level) && ($owner['id'] != $items[0]['contact-id'])) ? true : false); + $hub = get_config('system','huburl'); // If this is a public conversation, notify the feed hub @@ -591,7 +608,8 @@ function notifier_run($argv, $argc){ diaspora_send_relay($target_item,$owner,$contact); break; } - elseif($top_level) { + elseif(($top_level) && (! $walltowall)) { + // currently no workable solution for sending walltowall diaspora_send_status($target_item,$owner,$contact); break; } diff --git a/include/text.php b/include/text.php index 075caee00..78eae145e 100644 --- a/include/text.php +++ b/include/text.php @@ -610,12 +610,14 @@ function micropro($contact, $redirect = false, $class = '', $textmode = false) { if(! function_exists('search')) { -function search($s,$id='search-box',$url='/search') { +function search($s,$id='search-box',$url='/search',$save = false) { $a = get_app(); $o = '<div id="' . $id . '">'; $o .= '<form action="' . $a->get_baseurl() . $url . '" method="get" >'; $o .= '<input type="text" name="search" id="search-text" value="' . $s .'" />'; $o .= '<input type="submit" name="submit" id="search-submit" value="' . t('Search') . '" />'; + if($save) + $o .= '<input type="submit" name="save" id="search-save" value="' . t('Save') . '" />'; $o .= '</form></div>'; return $o; }} |