Merge remote-tracking branch 'upstream/develop' into rewrites/mixed-static-object-reference-calls

Signed-off-by: Roland Häder <roland@mxchange.org>

Conflicts:
	include/follow.php
This commit is contained in:
Roland Häder 2016-12-19 09:40:34 +01:00
commit ff569756ee
9 changed files with 5007 additions and 4877 deletions

View File

@ -93,20 +93,13 @@ function terminate_friendship($user,$self,$contact) {
if($contact['network'] === NETWORK_OSTATUS) {
$slap = replace_macros(get_markup_template('follow_slap.tpl'), array(
'$name' => $user['username'],
'$profile_page' => $a->get_baseurl() . '/profile/' . $user['nickname'],
'$photo' => $self['photo'],
'$thumb' => $self['thumb'],
'$published' => datetime_convert('UTC','UTC', 'now', ATOM_TIME),
'$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':unfollow:' . get_guid(32),
'$title' => '',
'$type' => 'text',
'$content' => t('stopped following'),
'$nick' => $user['nickname'],
'$verb' => 'http://ostatus.org/schema/1.0/unfollow', // ACTIVITY_UNFOLLOW,
'$ostat_follow' => '' // '<as:verb>http://ostatus.org/schema/1.0/unfollow</as:verb>' . "\r\n"
));
require_once('include/ostatus.php');
// create an unfollow slap
$item = array();
$item['verb'] = NAMESPACE_OSTATUS."/unfollow";
$item['follow'] = $contact["url"];
$slap = ostatus::salmon($item, $user);
if((x($contact,'notify')) && (strlen($contact['notify']))) {
require_once('include/salmon.php');

View File

@ -12,6 +12,7 @@ if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
require_once("boot.php");
require_once("include/photos.php");
require_once("include/user.php");
function cron_run(&$argv, &$argc){
@ -454,6 +455,16 @@ function cron_repair_diaspora(&$a) {
*/
function cron_repair_database() {
// Sometimes there seem to be issues where the "self" contact vanishes.
// We haven't found the origin of the problem by now.
$r = q("SELECT `uid` FROM `user` WHERE NOT EXISTS (SELECT `uid` FROM `contact` WHERE `contact`.`uid` = `user`.`uid` AND `contact`.`self`)");
if (dbm::is_result($r)) {
foreach ($r AS $user) {
logger('Create missing self contact for user '.$user['uid']);
user_create_self_contact($user['uid']);
}
}
// Set the parent if it wasn't set. (Shouldn't happen - but does sometimes)
// This call is very "cheap" so we can do it at any time without a problem
q("UPDATE `item` INNER JOIN `item` AS `parent` ON `parent`.`uri` = `item`.`parent-uri` AND `parent`.`uid` = `item`.`uid` SET `item`.`parent` = `parent`.`id` WHERE `item`.`parent` = 0");

View File

@ -2,6 +2,10 @@
require_once("include/Scrape.php");
require_once("include/socgraph.php");
require_once('include/group.php');
require_once('include/salmon.php');
require_once('include/ostatus.php');
require_once("include/Photo.php");
require_once('include/diaspora.php');
function update_contact($id) {
/*
@ -263,8 +267,6 @@ function new_contact($uid,$url,$interactive = false) {
if (intval($def_gid))
group_add_member($uid, '', $contact_id, $def_gid);
require_once("include/Photo.php");
// Update the avatar
update_contact_avatar($ret['photo'],$uid,$contact_id);
@ -272,36 +274,22 @@ function new_contact($uid,$url,$interactive = false) {
proc_run(PRIORITY_HIGH, "include/onepoll.php", $contact_id, "force");
// create a follow slap
$tpl = get_markup_template('follow_slap.tpl');
$slap = replace_macros($tpl, array(
'$name' => $a->user['username'],
'$profile_page' => $a->get_baseurl() . '/profile/' . $a->user['nickname'],
'$photo' => $a->contact['photo'],
'$thumb' => $a->contact['thumb'],
'$published' => datetime_convert('UTC','UTC', 'now', ATOM_TIME),
'$item_id' => 'urn:X-dfrn:' . $a->get_hostname() . ':follow:' . get_guid(32),
'$title' => '',
'$type' => 'text',
'$content' => t('following'),
'$nick' => $a->user['nickname'],
'$verb' => ACTIVITY_FOLLOW,
'$ostat_follow' => ''
));
$r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
intval($uid)
);
if (dbm::is_result($r)) {
if(($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
require_once('include/salmon.php');
slapper($r[0],$contact['notify'],$slap);
if (($contact['network'] == NETWORK_OSTATUS) && (strlen($contact['notify']))) {
// create a follow slap
$item = array();
$item['verb'] = ACTIVITY_FOLLOW;
$item['follow'] = $contact["url"];
$slap = ostatus::salmon($item, $r[0]);
slapper($r[0], $contact['notify'], $slap);
}
if($contact['network'] == NETWORK_DIASPORA) {
require_once('include/diaspora.php');
if ($contact['network'] == NETWORK_DIASPORA) {
$ret = diaspora::send_share($a->user,$contact);
logger('share returns: '.$ret);
}

View File

@ -467,7 +467,7 @@ class ostatus {
}
// Is it a repeated post?
if ($repeat_of != "") {
if (($repeat_of != "") OR ($item["verb"] == ACTIVITY_SHARE)) {
$activityobjects = $xpath->query('activity:object', $entry)->item(0);
if (is_object($activityobjects)) {
@ -1561,11 +1561,14 @@ class ostatus {
if ($xml)
return $xml;
if ($item["verb"] == ACTIVITY_LIKE)
if ($item["verb"] == ACTIVITY_LIKE) {
return self::like_entry($doc, $item, $owner, $toplevel);
else
} elseif (in_array($item["verb"], array(ACTIVITY_FOLLOW, NAMESPACE_OSTATUS."/unfollow"))) {
return self::follow_entry($doc, $item, $owner, $toplevel);
} else {
return self::note_entry($doc, $item, $owner, $toplevel);
}
}
/**
* @brief Adds a source entry to the XML document
@ -1740,6 +1743,113 @@ class ostatus {
return $entry;
}
/**
* @brief Adds the person object element to the XML document
*
* @param object $doc XML document
* @param array $owner Contact data of the poster
* @param array $contact Contact data of the target
*
* @return object author element
*/
private function add_person_object($doc, $owner, $contact) {
$object = $doc->createElement("activity:object");
xml::add_element($doc, $object, "activity:object-type", ACTIVITY_OBJ_PERSON);
if ($contact['network'] == NETWORK_PHANTOM) {
xml::add_element($doc, $object, "id", $contact['url']);
return $object;
}
xml::add_element($doc, $object, "id", $contact["alias"]);
xml::add_element($doc, $object, "title", $contact["nick"]);
$attributes = array("rel" => "alternate", "type" => "text/html", "href" => $contact["url"]);
xml::add_element($doc, $object, "link", "", $attributes);
$attributes = array(
"rel" => "avatar",
"type" => "image/jpeg", // To-Do?
"media:width" => 175,
"media:height" => 175,
"href" => $contact["photo"]);
xml::add_element($doc, $object, "link", "", $attributes);
xml::add_element($doc, $object, "poco:preferredUsername", $contact["nick"]);
xml::add_element($doc, $object, "poco:displayName", $contact["name"]);
if (trim($contact["location"]) != "") {
$element = $doc->createElement("poco:address");
xml::add_element($doc, $element, "poco:formatted", $contact["location"]);
$object->appendChild($element);
}
return $object;
}
/**
* @brief Adds a follow/unfollow entry element
*
* @param object $doc XML document
* @param array $item Data of the follow/unfollow message
* @param array $owner Contact data of the poster
* @param bool $toplevel Is it for en entry element (false) or a feed entry (true)?
*
* @return object Entry element
*/
private function follow_entry($doc, $item, $owner, $toplevel) {
$item["id"] = $item["parent"] = 0;
$item["created"] = $item["edited"] = date("c");
$item["private"] = true;
$contact = Probe::uri($item['follow']);
if ($contact['alias'] == '') {
$contact['alias'] = $contact["url"];
} else {
$item['follow'] = $contact['alias'];
}
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s'",
intval($owner['uid']), dbesc(normalise_link($contact["url"])));
if (dbm::is_result($r)) {
$connect_id = $r[0]['id'];
} else {
$connect_id = 0;
}
if ($item['verb'] == ACTIVITY_FOLLOW) {
$message = t('%s is now following %s.');
$title = t('following');
$action = "subscription";
} else {
$message = t('%s stopped following %s.');
$title = t('stopped following');
$action = "unfollow";
}
$item["uri"] = $item['parent-uri'] = $item['thr-parent'] =
'tag:'.get_app()->get_hostname().
','.date('Y-m-d').':'.$action.':'.$owner['uid'].
':person:'.$connect_id.':'.$item['created'];
$item["body"] = sprintf($message, $owner["nick"], $contact["nick"]);
self::entry_header($doc, $entry, $owner, $toplevel);
self::entry_content($doc, $entry, $item, $owner, $title);
$object = self::add_person_object($doc, $owner, $contact);
$entry->appendChild($object);
self::entry_footer($doc, $entry, $item, $owner);
return $entry;
}
/**
* @brief Adds a regular entry element
*
@ -1832,7 +1942,7 @@ class ostatus {
xml::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
"href" => App::get_baseurl()."/display/".$item["guid"]));
if ($complete)
if ($complete AND ($item["id"] > 0))
xml::add_element($doc, $entry, "status_net", "", array("notice_id" => $item["id"]));
xml::add_element($doc, $entry, "activity:verb", $verb);
@ -1881,9 +1991,11 @@ class ostatus {
}
}
xml::add_element($doc, $entry, "link", "", array("rel" => "ostatus:conversation",
"href" => App::get_baseurl()."/display/".$owner["nick"]."/".$item["parent"]));
xml::add_element($doc, $entry, "ostatus:conversation", App::get_baseurl()."/display/".$owner["nick"]."/".$item["parent"]);
if (intval($item["parent"]) > 0) {
$conversation = App::get_baseurl()."/display/".$owner["nick"]."/".$item["parent"];
xml::add_element($doc, $entry, "link", "", array("rel" => "ostatus:conversation", "href" => $conversation));
xml::add_element($doc, $entry, "ostatus:conversation", $conversation);
}
$tags = item_getfeedtags($item);
@ -1929,7 +2041,7 @@ class ostatus {
self::get_attachment($doc, $entry, $item);
if ($complete) {
if ($complete AND ($item["id"] > 0)) {
$app = $item["app"];
if ($app == "")
$app = "web";

View File

@ -63,6 +63,10 @@ function get_old_attachment_data($body) {
$post["url"] = $matches[1];
$post["title"] = $matches[2];
}
if (($post["url"] == "") AND (in_array($post["type"], array("link", "video")))
AND preg_match("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", $attacheddata, $matches)) {
$post["url"] = $matches[1];
}
// Search for description
if (preg_match("/\[quote\](.*?)\[\/quote\]/ism", $attacheddata, $matches))

View File

@ -269,28 +269,9 @@ function create_user($arr) {
intval($newuid));
return $result;
}
$r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`,
`addr`, `request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date`, `closeness` )
VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', 0 ) ",
intval($newuid),
datetime_convert(),
dbesc($username),
dbesc($nickname),
dbesc(z_root() . "/photo/profile/{$newuid}.jpg"),
dbesc(z_root() . "/photo/avatar/{$newuid}.jpg"),
dbesc(z_root() . "/photo/micro/{$newuid}.jpg"),
dbesc(z_root() . "/profile/$nickname"),
dbesc(normalise_link(z_root() . "/profile/$nickname")),
dbesc($nickname . '@' . substr(z_root(), strpos(z_root(),'://') + 3 )),
dbesc(z_root() . "/dfrn_request/$nickname"),
dbesc(z_root() . "/dfrn_notify/$nickname"),
dbesc(z_root() . "/dfrn_poll/$nickname"),
dbesc(z_root() . "/dfrn_confirm/$nickname"),
dbesc(z_root() . "/poco/$nickname"),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert())
);
// Create the self contact
user_create_self_contact($newuid);
// Create a group with no members. This allows somebody to use it
// right away as a default group for new contacts.
@ -377,6 +358,49 @@ function create_user($arr) {
}
/**
* @brief create the "self" contact from data from the user table
*
* @param integer $uid
*/
function user_create_self_contact($uid) {
// Only create the entry if it doesn't exist yet
$r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($uid));
if (dbm::is_result($r)) {
return;
}
$r = q("SELECT `uid`, `username`, `nickname` FROM `user` WHERE `uid` = %d", intval($uid));
if (!dbm::is_result($r)) {
return;
}
$user = $r[0];
q("INSERT INTO `contact` (`uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`,
`addr`, `request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date`, `closeness`)
VALUES (%d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', 0)",
intval($user['uid']),
datetime_convert(),
dbesc($user['username']),
dbesc($user['nickname']),
dbesc(z_root()."/photo/profile/".$user['uid'].".jpg"),
dbesc(z_root()."/photo/avatar/".$user['uid'].".jpg"),
dbesc(z_root()."/photo/micro/".$user['uid'].".jpg"),
dbesc(z_root()."/profile/".$user['nickname']),
dbesc(normalise_link(z_root()."/profile/".$user['nickname'])),
dbesc($user['nickname'].'@'.substr(z_root(), strpos(z_root(),'://') + 3)),
dbesc(z_root()."/dfrn_request/".$user['nickname']),
dbesc(z_root()."/dfrn_notify/".$user['nickname']),
dbesc(z_root()."/dfrn_poll/".$user['nickname']),
dbesc(z_root()."/dfrn_confirm/".$user['nickname']),
dbesc(z_root()."/poco/".$user['nickname']),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert())
);
}
/**
* @brief send registration confiŕmation with the intormation that reg is pending

View File

@ -548,10 +548,15 @@ function check_imagik(&$checks) {
$gif = true;
}
}
if ($imagick == false) {
check_add($checks, t('ImageMagick PHP extension is not installed'), $imagick, false, "");
}
else {
check_add($checks, t('ImageMagick PHP extension is installed'), $imagick, false, "");
if ($imagick) {
check_add($checks, t('ImageMagick supports GIF'), $gif, false, "");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
<entry>
<author>
<name>{{$name}}</name>
<uri>{{$profile_page}}</uri>
<link rel="photo" type="image/jpeg" media:width="80" media:height="80" href="{{$thumb}}" />
<link rel="avatar" type="image/jpeg" media:width="80" media:height="80" href="{{$thumb}}" />
</author>
<id>{{$item_id}}</id>
<title>{{$title}}</title>
<published>{{$published}}</published>
<content type="{{$type}}" >{{$content}}</content>
<as:actor>
<as:object-type>http://activitystrea.ms/schema/1.0/person</as:object-type>
<id>{{$profile_page}}</id>
<title></title>
<link rel="avatar" type="image/jpeg" media:width="175" media:height="175" href="{{$photo}}"/>
<link rel="avatar" type="image/jpeg" media:width="80" media:height="80" href="{{$thumb}}"/>
<poco:preferredUsername>{{$nick}}</poco:preferredUsername>
<poco:displayName>{{$name}}</poco:displayName>
</as:actor>
<as:verb>{{$verb}}</as:verb>
{{$ostat_follow}}
</entry>