Merge pull request #546 from annando/master

Bugfix in mail import - use of the "share" element in ostatus and diaspora items
This commit is contained in:
friendica 2012-12-19 22:54:53 -08:00
commit 898f68938a
12 changed files with 213 additions and 40 deletions

View file

@ -251,11 +251,11 @@ function bb_ShareAttributes($match) {
if ($avatar != "")
$headline .= '<img src="'.$avatar.'" height="32" width="32" >';
$headline .= sprintf(t('<span><a href="%s">%s</a> wrote the following <a href="%s">post</a>:</span>'), $profile, $author, $link);
$headline .= sprintf(t('<span><a href="%s" target="external-link">%s</a> wrote the following <a href="%s" target="external-link">post</a>:</span>'), $profile, $author, $link);
$headline .= "</div>";
$text = "<br />".$headline.'<blockquote class="shared_content">'.trim($match[2])."</blockquote>";
$text = $headline.'<blockquote class="shared_content">'.trim($match[2])."</blockquote>";
return($text);
}
@ -314,6 +314,7 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// We'll emulate it.
$Text = trim($Text);
$Text = str_replace("\r\n","\n", $Text);
$Text = str_replace(array("\r","\n"), array('<br />','<br />'), $Text);

View file

@ -481,13 +481,28 @@ function delivery_run(&$argv, &$argc){
//logger("Mail: Data: ".print_r($it, true), LOGGER_DATA);
if($it['uri'] !== $it['parent-uri']) {
$headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
if(!strlen($it['title'])) {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
dbesc($it['parent-uri']));
$headers .= "References: <".iri2msgid($it["parent-uri"]).">";
// If Threading is enabled, write down the correct parent
if (($it["thr-parent"] != "") and ($it["thr-parent"] != $it["parent-uri"]))
$headers .= " <".iri2msgid($it["thr-parent"]).">";
$headers .= "\n";
if(!$it['title']) {
$r = q("SELECT `title` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));
if(count($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title'];
else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));
if(count($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title'];
}
}
if(strncasecmp($subject,'RE:',3))
$subject = 'Re: '.$subject;

View file

@ -923,6 +923,7 @@ function diaspora_reshare($importer,$xml,$msg) {
$orig_guid = notags(unxmlify($xml->root_guid));
$source_url = 'https://' . substr($orig_author,strpos($orig_author,'@')+1) . '/p/' . $orig_guid . '.xml';
$orig_url = 'https://'.substr($orig_author,strpos($orig_author,'@')+1).'/posts/'.$orig_guid;
$x = fetch_url($source_url);
if(! $x)
$x = fetch_url(str_replace('https://','http://',$source_url));
@ -1032,10 +1033,14 @@ function diaspora_reshare($importer,$xml,$msg) {
$datarray['author-avatar'] = ((x($person,'thumb')) ? $person['thumb'] : $person['photo']);
$datarray['body'] = $body;
} else {
$prefix = "[share author='".$person['name'].
"' profile='".$person['url'].
"' avatar='".((x($person,'thumb')) ? $person['thumb'] : $person['photo']).
"' link='".$orig_url."']";
$datarray['author-name'] = $contact['name'];
$datarray['author-link'] = $contact['url'];
$datarray['author-avatar'] = $contact['thumb'];
$datarray['body'] = $prefix . $body;
$datarray['body'] = $prefix.$body."[/share]";
}
$datarray['tag'] = $str_tags;

View file

@ -798,6 +798,7 @@ function get_atom_elements($feed,$item) {
logger('get_atom_elements: Looking for status.net repeated message');
$message = $child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["content"][0]["data"];
$orig_uri = $child["http://activitystrea.ms/spec/1.0/"]["object"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["id"][0]["data"];
$author = $child[SIMPLEPIE_NAMESPACE_ATOM_10]["author"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10];
$uri = $author["uri"][0]["data"];
$name = $author["name"][0]["data"];
@ -805,17 +806,22 @@ function get_atom_elements($feed,$item) {
$avatar = $avatar["href"];
if (($name != "") and ($uri != "") and ($avatar != "") and ($message != "")) {
logger('get_atom_elements: fixing sender of repeated message');
logger('get_atom_elements: fixing sender of repeated message.');
$res["owner-name"] = $res["author-name"];
/*$res["owner-name"] = $res["author-name"];
$res["owner-link"] = $res["author-link"];
$res["owner-avatar"] = $res["author-avatar"];
$res["author-name"] = $name;
$res["author-link"] = $uri;
$res["author-avatar"] = $avatar;
$res["author-avatar"] = $avatar;*/
$res["body"] = html2bbcode($message);
$prefix = "[share author='".$name.
"' profile='".$uri.
"' avatar='".$avatar.
"' link='".$orig_uri."']";
$res["body"] = $prefix.html2bbcode($message)."[/share]";
}
}

View file

@ -15,6 +15,9 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
@curl_setopt($ch, CURLOPT_HEADER, true);
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
if (!is_null($accept_content)){
curl_setopt($ch,CURLOPT_HTTPHEADER, array (
"Accept: " . $accept_content

View file

@ -790,13 +790,28 @@ function notifier_run(&$argv, &$argc){
$headers .= 'Message-Id: <' . iri2msgid($it['uri']) . '>' . "\n";
if($it['uri'] !== $it['parent-uri']) {
$headers .= 'References: <' . iri2msgid($it['parent-uri']) . '>' . "\n";
if(!strlen($it['title'])) {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1",
dbesc($it['parent-uri']));
$headers .= "References: <".iri2msgid($it["parent-uri"]).">";
// If Threading is enabled, write down the correct parent
if (($it["thr-parent"] != "") and ($it["thr-parent"] != $it["parent-uri"]))
$headers .= " <".iri2msgid($it["thr-parent"]).">";
$headers .= "\n";
if(!$it['title']) {
$r = q("SELECT `title` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));
if(count($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title'];
else {
$r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d LIMIT 1",
dbesc($it['parent-uri']),
intval($uid));
if(count($r) AND ($r[0]['title'] != ''))
$subject = $r[0]['title'];
}
}
if(strncasecmp($subject,'RE:',3))
$subject = 'Re: '.$subject;

View file

@ -335,7 +335,7 @@ function onepoll_run(&$argv, &$argc){
intval($r[0]['id'])
);
}
/*switch ($mailconf[0]['action']) {
switch ($mailconf[0]['action']) {
case 0:
logger("Mail: Seen before ".$msg_uid." for ".$mailconf[0]['user'].". Doing nothing.", LOGGER_DEBUG);
break;
@ -353,7 +353,7 @@ function onepoll_run(&$argv, &$argc){
if ($mailconf[0]['movetofolder'] != "")
imap_mail_move($mbox, $msg_uid, $mailconf[0]['movetofolder'], FT_UID);
break;
}*/
}
continue;
}
@ -405,8 +405,9 @@ function onepoll_run(&$argv, &$argc){
// If it seems to be a reply but a header couldn't be found take the last message with matching subject
if(!x($datarray,'parent-uri') and $reply) {
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) ORDER BY `created` DESC LIMIT 1",
dbesc(protect_sprintf($datarray['title'])));
$r = q("SELECT `uri` , `parent-uri` FROM `item` WHERE MATCH (`title`) AGAINST ('".'"%s"'."' IN BOOLEAN MODE) AND `uid` = %d ORDER BY `created` DESC LIMIT 1",
dbesc(protect_sprintf($datarray['title'])),
intval($importer_uid));
if(count($r))
$datarray['parent-uri'] = $r[0]['parent-uri'];
}
@ -436,7 +437,29 @@ function onepoll_run(&$argv, &$argc){
else
$fromdecoded .= $frompart->text;
$datarray['body'] = "[b]".t('From: ') . escape_tags($fromdecoded) . "[/b]\n\n" . $datarray['body'];
$fromarr = imap_rfc822_parse_adrlist($fromdecoded, $a->get_hostname());
$frommail = $fromarr[0]->mailbox."@".$fromarr[0]->host;
if (isset($fromarr[0]->personal))
$fromname = $fromarr[0]->personal;
else
$fromname = $frommail;
//$datarray['body'] = "[b]".t('From: ') . escape_tags($fromdecoded) . "[/b]\n\n" . $datarray['body'];
$datarray['author-name'] = $fromname;
$datarray['author-link'] = "mailto:".$frommail;
$datarray['author-avatar'] = $contact['photo'];
$datarray['owner-name'] = $contact['name'];
$datarray['owner-link'] = "mailto:".$contact['addr'];
$datarray['owner-avatar'] = $contact['photo'];
} else {
$datarray['author-name'] = $contact['name'];
$datarray['author-link'] = 'mailbox';
$datarray['author-avatar'] = $contact['photo'];
}
$datarray['uid'] = $importer_uid;
@ -447,9 +470,6 @@ function onepoll_run(&$argv, &$argc){
$datarray['private'] = 1;
$datarray['allow_cid'] = '<' . $contact['id'] . '>';
}
$datarray['author-name'] = $contact['name'];
$datarray['author-link'] = 'mailbox';
$datarray['author-avatar'] = $contact['photo'];
$stored_item = item_store($datarray);
q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d",

View file

@ -982,6 +982,9 @@ function prepare_body($item,$attach = false) {
$s = $prep_arr['html'];
if(! $attach) {
// Replace the blockquotes with quotes that are used in mails
$mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">';
$s = str_replace(array('<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'), array($mailquote, $mailquote, $mailquote), $s);
return $s;
}

View file

@ -1024,6 +1024,7 @@ $a->strings["Delegate Page Management"] = "Delegiere das Management für die Sei
$a->strings["Delegates are able to manage all aspects of this account/page except for basic account settings. Please do not delegate your personal account to anybody that you do not trust completely."] = "Bevollmächtigte sind in der Lage, alle Aspekte dieses Kontos/dieser Seite zu verwalten, abgesehen von den Grundeinstellungen des Kontos. Bitte gib niemandem eine Bevollmächtigung für deinen privaten Account, dem du nicht absolut vertraust!";
$a->strings["Existing Page Managers"] = "Vorhandene Seiten Manager";
$a->strings["Existing Page Delegates"] = "Vorhandene Bevollmächtigte für die Seite";
$a->strings["Delegations"] = "Bevollmächtigungen";
$a->strings["Potential Delegates"] = "Potentielle Bevollmächtigte";
$a->strings["Add"] = "Hinzufügen";
$a->strings["No entries."] = "Keine Einträge";
@ -2076,7 +2077,7 @@ $a->strings["Birthday Reminders"] = "Geburtstagserinnerungen";
$a->strings["Birthdays this week:"] = "Geburtstage diese Woche:";
$a->strings["[No description]"] = "[keine Beschreibung]";
$a->strings["Event Reminders"] = "Veranstaltungserinnerungen";
$a->strings["Events this week:"] = "Veranstaltungen diese Woche";
$a->strings["Events this week:"] = "Veranstaltungen diese Woche:";
$a->strings["Status Messages and Posts"] = "Statusnachrichten und Beiträge";
$a->strings["Profile Details"] = "Profildetails";
$a->strings["Events and Calendar"] = "Ereignisse und Kalender";
@ -2097,5 +2098,7 @@ $a->strings["Post to Drupal by default"] = "Veröffentliche öffentliche Beiträ
$a->strings["OEmbed settings updated"] = "OEmbed Einstellungen aktualisiert.";
$a->strings["Use OEmbed for YouTube videos"] = "OEmbed für Youtube Videos verwenden";
$a->strings["URL to embed:"] = "URL zum Einbetten:";
$a->strings['<span><a href="%s" target="external-link">%s</a> wrote the following <a href="%s" target="external-link">post</a>:</span>'] =
'<span><a href="%s" target="external-link">%s</a> hat diesen <a href="%s" target="external-link">Beitrag</a> ursprünglich gepostet:</span>';
$a->strings["Tumblr login"] = "Tumblr Login";
$a->strings["Tumblr password"] = "Tumblr Passwort";

View file

@ -0,0 +1,50 @@
{{ if $threaded }}
<div class="comment-wwedit-wrapper threaded" id="comment-edit-wrapper-$id" style="display: block;">
{{ else }}
<div class="comment-wwedit-wrapper" id="comment-edit-wrapper-$id" style="display: block;">
{{ endif }}
<form class="comment-edit-form" style="display: block;" id="comment-edit-form-$id" action="item" method="post" onsubmit="post_comment($id); return false;">
<input type="hidden" name="type" value="$type" />
<input type="hidden" name="profile_uid" value="$profile_uid" />
<input type="hidden" name="parent" value="$parent" />
<input type="hidden" name="return" value="$return_path" />
<input type="hidden" name="jsreload" value="$jsreload" />
<input type="hidden" name="preview" id="comment-preview-inp-$id" value="0" />
<input type="hidden" name="post_id_random" value="$rand_num" />
<div class="comment-edit-photo" id="comment-edit-photo-$id" >
<a class="comment-edit-photo-link" href="$mylink" title="$mytitle"><img class="my-comment-photo" src="$myphoto" alt="$mytitle" title="$mytitle" /></a>
</div>
<div class="comment-edit-photo-end"></div>
<textarea id="comment-edit-text-$id" class="comment-edit-text-empty" name="body" onFocus="commentOpen(this,$id);">$comment</textarea>
{{ if $qcomment }}
<select id="qcomment-select-$id" name="qcomment-$id" class="qcomment" onchange="qCommentInsert(this,$id);" >
<option value=""></option>
{{ for $qcomment as $qc }}
<option value="$qc">$qc</option>
{{ endfor }}
</select>
{{ endif }}
<div class="comment-edit-text-end"></div>
<div class="comment-edit-submit-wrapper" id="comment-edit-submit-wrapper-$id" style="display: none;" >
<div class="comment-edit-bb-$id">
<a class="icon bb-image" style="cursor: pointer;" title="$edimg" onclick="insertFormatting('$comment','img',$id);">img</a>
<a class="icon bb-url" style="cursor: pointer;" title="$edurl" onclick="insertFormatting('$comment','url',$id);">url</a>
<a class="icon bb-video" style="cursor: pointer;" title="$edvideo" onclick="insertFormatting('$comment','video',$id);">video</a>
<a class="icon underline" style="cursor: pointer;" title="$eduline" onclick="insertFormatting('$comment','u',$id);">u</a>
<a class="icon italic" style="cursor: pointer;" title="$editalic" onclick="insertFormatting('$comment','i',$id);">i</a>
<a class="icon bold" style="cursor: pointer;" title="$edbold" onclick="insertFormatting('$comment','b',$id);">b</a>
<a class="icon quote" style="cursor: pointer;" title="$edquote" onclick="insertFormatting('$comment','quote',$id);">quote</a>
</div>
<input type="submit" onclick="post_comment($id); return false;" id="comment-edit-submit-$id" class="comment-edit-submit" name="submit" value="$submit" />
<span onclick="preview_comment($id);" id="comment-edit-preview-link-$id" class="fakelink">$preview</span>
<div id="comment-edit-preview-$id" class="comment-edit-preview" style="display:none;"></div>
</div>
<div class="comment-edit-end"></div>
</form>
</div>

View file

@ -86,6 +86,34 @@
#adminpage .selectall { text-align: right; }
/* icons */
.icon.bb-url{
background-image: url("../../../view/theme/diabook/icons/bb-url.png");
float: right;
margin-top: 2px;}
.icon.quote{
background-image: url("../../../view/theme/diabook/icons/quote.png");
float: right;
margin-top: 2px;}
.icon.bold{
background-image: url("../../../view/theme/diabook/icons/bold.png");
float: right;
margin-top: 2px;}
.icon.underline{
background-image: url("../../../view/theme/diabook/icons/underline.png");
float: right;
margin-top: 2px;}
.icon.italic{
background-image: url("../../../view/theme/diabook/icons/italic.png");
float: right;
margin-top: 2px;}
.icon.bb-image{
background-image: url("../../../view/theme/diabook/icons/bb-image.png");
float: right;
margin-top: 2px;}
.icon.bb-video{
background-image: url("../../../view/theme/diabook/icons/bb-video.png");
float: right;
margin-top: 2px;}
.article { background-position: -50px 0px;}
.audio { background-position: -70px 0px;}
@ -313,6 +341,10 @@
cursor: url('lock.cur'), pointer;
}
#birthday-title, #event-title {
font-weight: bold;
margin-bottom: 5px;
}
div.pager, .birthday-notice {
text-align: center;
@ -356,8 +388,8 @@ div.pager, .birthday-notice {
height: 32px;
color: #999;
border-top: 1px solid #D2D2D2;
padding-top: 16px;
margin-top: 16px;
padding-top: 5px;
margin-top: 5px;
}
.shared_header img {
@ -1212,8 +1244,11 @@ border-bottom: 1px solid #D2D2D2;
.wall-item-container.comment .wall-item-links {
padding-left: 12px;
}
.wall-item-bottom .wall-item-comment-wrapper {
margin: 1px 5px 1px 0px;
}
.wall-item-comment-wrapper {
margin: 1px 5px 1px 80px;
margin: 1px 15px 1px 80px;
}
.wall-item-comment-wrapper .comment-edit-photo {
display: none;
@ -1238,11 +1273,6 @@ border-bottom: 1px solid #D2D2D2;
margin-right: 1em;
}
.comment-edit-preview {
width: 710px;
border: 1px solid #2d2d2d;
margin-top: 10px;
}
.comment-edit-preview .contact-photo {
width: 32px;
height: 32px;
@ -1251,6 +1281,9 @@ border-bottom: 1px solid #D2D2D2;
}
.comment-edit-preview {
width: 660px;
border: 1px solid #2d2d2d;
margin-top: 10px;
top: 15px !important;
left: 15px !important;
}
@ -1264,6 +1297,12 @@ border-bottom: 1px solid #D2D2D2;
width: 700px;
padding: 0;
margin: 10px 0;
border-bottom: 0px;
}
.wall-item-bottom .comment-edit-preview {
width: 575px;
margin-bottom: 5px;
}
.shiny {
@ -1303,6 +1342,10 @@ border-bottom: 1px solid #D2D2D2;
height: 100px;
}
#jot-preview-content {
padding-top: 25px;
}
#jot-preview-content .tread-wrapper {
background-color: #fce94f;
}
@ -1694,10 +1737,15 @@ ul.tabs li {
/*ul.tabs li .active {
border-bottom: 1px solid #005c94;
}*/
ul.tabs a {
display: block;
float: left;
padding: 0px 10px 1px 10px;
}
ul.tabs a, #jot-preview-link, .comment-edit-submit-wrapper .fakelink {
/* padding: 0px 10px 1px 10px; */
padding: 0px 5px 1px 5px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
@ -1715,7 +1763,9 @@ ul.tabs a {
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ececf2',GradientType=0 );
background: linear-gradient(top, #ffffff 0%,#ececf2 100%);
}
ul.tabs li .active, ul.tabs a:hover {
ul.tabs li .active, ul.tabs a:hover, #jot-preview-link:hover, .comment-edit-submit-wrapper .fakelink:hover {
color: #fff;
text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.5);
border: 1px solid #ececf2;

View file

@ -12,7 +12,7 @@ $a->theme_info = array();
function vier_init(&$a) {
$a->page['htmlhead'] .= <<< EOT
<script>
/*function insertFormatting(comment,BBcode,id) {
function insertFormatting(comment,BBcode,id) {
var tmpStr = $("#comment-edit-text-" + id).val();
if(tmpStr == comment) {
@ -41,7 +41,7 @@ $a->page['htmlhead'] .= <<< EOT
}
return true;
}
*/
function showThread(id) {
$("#collapsed-comments-" + id).show()
@ -52,13 +52,15 @@ function hideThread(id) {
$("#collapsed-comments-" + id + " .collapsed-comments").hide()
}
/*
function cmtBbOpen(id) {
$("#comment-edit-bb-" + id).show();
}
function cmtBbClose(id) {
$("#comment-edit-bb-" + id).hide();
}
/*
$(document).ready(function() {
$('html').click(function() { $("#nav-notifications-menu" ).hide(); });