require_once('include/threads.php');
require_once('include/text.php');
require_once('include/items.php');
+require_once('include/Scrape.php');
function item_post(&$a) {
intval($parent_item['contact-id']),
intval($uid)
);
- if(count($r)) {
+ if(count($r))
$parent_contact = $r[0];
- // If the contact id doesn't fit with the contact, then set the contact to null
- $thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent));
- if (count($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS)
- AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
- $parent_contact = null;
-
- require_once("include/Scrape.php");
- $probed_contact = probe_url($thrparent[0]["author-link"]);
- if ($probed_contact["network"] != NETWORK_FEED) {
- $parent_contact = $probed_contact;
- $parent_contact["nurl"] = normalise_link($probed_contact["url"]);
- $parent_contact["thumb"] = $probed_contact["photo"];
- $parent_contact["micro"] = $probed_contact["photo"];
- }
- logger('parent contact: '.print_r($parent_contact, true), LOGGER_DEBUG);
- } else
- logger('no contact found: '.print_r($thrparent, true), LOGGER_DEBUG);
- }
+ // If the contact id doesn't fit with the contact, then set the contact to null
+ $thrparent = q("SELECT `author-link`, `network` FROM `item` WHERE `uri` = '%s' LIMIT 1", dbesc($thr_parent));
+ if (count($thrparent) AND ($thrparent[0]["network"] === NETWORK_OSTATUS)
+ AND (normalise_link($parent_contact["url"]) != normalise_link($thrparent[0]["author-link"]))) {
+ $parent_contact = null;
+
+ require_once("include/Scrape.php");
+ $probed_contact = probe_url($thrparent[0]["author-link"]);
+ if ($probed_contact["network"] != NETWORK_FEED) {
+ $parent_contact = $probed_contact;
+ $parent_contact["nurl"] = normalise_link($probed_contact["url"]);
+ $parent_contact["thumb"] = $probed_contact["photo"];
+ $parent_contact["micro"] = $probed_contact["photo"];
+ $parent_contact["addr"] = $probed_contact["addr"];
+ }
+ logger('no contact found: '.print_r($thrparent, true), LOGGER_DEBUG);
+ } else
+ logger('parent contact: '.print_r($parent_contact, true), LOGGER_DEBUG);
}
}
} else {
- // if coming from the API and no privacy settings are set,
+ // if coming from the API and no privacy settings are set,
// use the user default permissions - as they won't have
// been supplied via a form.
- if(($api_source)
+ if(($api_source)
&& (! array_key_exists('contact_allow',$_REQUEST))
&& (! array_key_exists('group_allow',$_REQUEST))
&& (! array_key_exists('contact_deny',$_REQUEST))
// Work around doubled linefeeds in Tinymce 3.5b2
// First figure out if it's a status post that would've been
- // created using tinymce. Otherwise leave it alone.
+ // created using tinymce. Otherwise leave it alone.
/* $plaintext = (local_user() ? intval(get_pconfig(local_user(),'system','plaintext')) || !feature_enabled($profile_uid,'richtext') : 0);
if((! $parent) && (! $api_source) && (! $plaintext)) {
* Fold multi-line [code] sequences
*/
- $body = preg_replace('/\[\/code\]\s*\[code\]/ism',"\n",$body);
+ $body = preg_replace('/\[\/code\]\s*\[code\]/ism',"\n",$body);
$body = scale_external_images($body,false);
* and we are replying, and there isn't one already
*/
- if(($parent_contact) && ($parent_contact['network'] === NETWORK_OSTATUS)
- && ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) {
- $body = '@' . $parent_contact['nick'] . ' ' . $body;
- $tags[] = '@' . $parent_contact['nick'];
+ if($parent AND ($parent_contact['network'] === NETWORK_OSTATUS)) {
+ if ($parent_contact['id'] != "")
+ $contact = '@'.$parent_contact['nick'].'+'.$parent_contact['id'];
+ else
+ $contact = '@[url='.$parent_contact['url'].']'.$parent_contact['nick'].'[/url]';
+
+ if (!in_array($contact,$tags)) {
+ $body = $contact.' '.$body;
+ $tags[] = $contact;
+ }
+
+ $toplevel_contact = "";
+ $toplevel_parent = q("SELECT `contact`.* FROM `contact`
+ INNER JOIN `item` ON `item`.`contact-id` = `contact`.`id` AND `contact`.`url` = `item`.`author-link`
+ WHERE `item`.`id` = `item`.`parent` AND `item`.`parent` = %d", intval($parent));
+ if ($toplevel_parent)
+ $toplevel_contact = '@'.$toplevel_parent[0]['nick'].'+'.$toplevel_parent[0]['id'];
+ else {
+ $toplevel_parent = q("SELECT `author-link`, `author-name` FROM `item` WHERE `id` = `parent` AND `parent` = %d", intval($parent));
+ $toplevel_contact = '@[url='.$toplevel_parent[0]['author-link'].']'.$toplevel_parent[0]['author-name'].'[/url]';
+ }
+
+ if (!in_array($toplevel_contact,$tags))
+ $tags[] = $toplevel_contact;
}
$tagged = array();
if(count($r)) {
if(strlen($attachments))
$attachments .= ',';
- $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
+ $attachments .= '[attach]href="' . $a->get_baseurl() . '/attach/' . $r[0]['id'] . '" length="' . $r[0]['filesize'] . '" type="' . $r[0]['filetype'] . '" title="' . (($r[0]['filename']) ? $r[0]['filename'] : '') . '"[/attach]';
}
$body = str_replace($match[1],'',$body);
}
$gravity = (($parent) ? 6 : 0 );
- // even if the post arrived via API we are considering that it
+ // even if the post arrived via API we are considering that it
// originated on this site by default for determining relayability.
$origin = ((x($_REQUEST,'origin')) ? intval($_REQUEST['origin']) : 1);
// NOTREACHED
}
+ // Store the guid and other relevant data
+ add_guid($datarray);
+
$post_id = $r[0]['id'];
logger('mod_item: saved item ' . $post_id);
$addr = trim($recip);
if(! strlen($addr))
continue;
- $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
+ $disclaimer = '<hr />' . sprintf( t('This message was sent to you by %s, a member of the Friendica social network.'),$a->user['username'])
. '<br />';
$disclaimer .= sprintf( t('You may visit them online at %s'), $a->get_baseurl() . '/profile/' . $a->user['nickname']) . EOL;
- $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
+ $disclaimer .= t('Please contact the sender by replying to this post if you do not wish to receive these messages.') . EOL;
if (!$datarray['title']=='') {
$subject = email_header_encode($datarray['title'],'UTF-8');
} else {
'htmlVersion' => $message,
'textVersion' => html2plain($html.$disclaimer),
);
- enotify::send($params);
+ Emailer::send($params);
}
}
}
//is it a person tag?
if(strpos($tag,'@') === 0) {
//is it already replaced?
- if(strpos($tag,'[url='))
+ if(strpos($tag,'[url=')) {
+ //append tag to str_tags
+ if(!stristr($str_tags,$tag)) {
+ if(strlen($str_tags))
+ $str_tags .= ',';
+ $str_tags .= $tag;
+ }
+
+ // Checking for the alias that is used for OStatus
+ $pattern = "/@\[url\=(.*?)\](.*?)\[\/url\]/ism";
+ if (preg_match($pattern, $tag, $matches)) {
+ $data = probe_url($matches[1]);
+ if ($data["alias"] != "") {
+ $newtag = '@[url='.$data["alias"].']'.$data["name"].'[/url]';
+ if(!stristr($str_tags,$newtag)) {
+ if(strlen($str_tags))
+ $str_tags .= ',';
+ $str_tags .= $newtag;
+ }
+ }
+ }
+
return $replaced;
+ }
$stat = false;
//get the person's name
$name = substr($tag,1);