When storing items, the object-type is detected and stored.

This commit is contained in:
Michael Vogel 2014-08-07 08:02:24 +02:00
parent 2ba258e1ca
commit f2f73799ba

View file

@ -77,9 +77,12 @@ function item_post(&$a) {
$thr_parent = ''; $thr_parent = '';
$parid = 0; $parid = 0;
$r = false; $r = false;
$objecttype = null;
if($parent || $parent_uri) { if($parent || $parent_uri) {
$objecttype = ACTIVITY_OBJ_COMMENT;
if(! x($_REQUEST,'type')) if(! x($_REQUEST,'type'))
$_REQUEST['type'] = 'net-comment'; $_REQUEST['type'] = 'net-comment';
@ -195,6 +198,7 @@ function item_post(&$a) {
$location = $orig_post['location']; $location = $orig_post['location'];
$coord = $orig_post['coord']; $coord = $orig_post['coord'];
$verb = $orig_post['verb']; $verb = $orig_post['verb'];
$objecttype = $orig_post['object-type'];
$emailcc = $orig_post['emailcc']; $emailcc = $orig_post['emailcc'];
$app = $orig_post['app']; $app = $orig_post['app'];
$categories = $orig_post['file']; $categories = $orig_post['file'];
@ -425,6 +429,9 @@ function item_post(&$a) {
if((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) { if((! $preview) && preg_match_all("/\[img([\=0-9x]*?)\](.*?)\[\/img\]/",$body,$match)) {
$images = $match[2]; $images = $match[2];
if(count($images)) { if(count($images)) {
$objecttype = ACTIVITY_OBJ_IMAGE;
foreach($images as $image) { foreach($images as $image) {
if(! stristr($image,$a->get_baseurl() . '/photo/')) if(! stristr($image,$a->get_baseurl() . '/photo/'))
continue; continue;
@ -494,6 +501,7 @@ function item_post(&$a) {
$bookmark = 0; $bookmark = 0;
if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match,PREG_SET_ORDER)) { if(preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism",$body,$match,PREG_SET_ORDER)) {
$objecttype = ACTIVITY_OBJ_BOOKMARK;
$bookmark = 1; $bookmark = 1;
} }
@ -509,6 +517,20 @@ function item_post(&$a) {
$body = scale_external_images($body,false); $body = scale_external_images($body,false);
// Setting the object type if not defined before
if (!$objecttype) {
$objecttype = ACTIVITY_OBJ_NOTE; // Default value
require_once("include/plaintext.php");
$objectdata = get_attached_data($body);
if ($post["type"] == "link")
$objecttype = ACTIVITY_OBJ_BOOKMARK;
elseif ($post["type"] == "video")
$objecttype = ACTIVITY_OBJ_VIDEO;
elseif ($post["type"] == "photo")
$objecttype = ACTIVITY_OBJ_IMAGE;
}
/** /**
* Look for any tags and linkify them * Look for any tags and linkify them
@ -641,6 +663,7 @@ function item_post(&$a) {
$datarray['file'] = $categories; $datarray['file'] = $categories;
$datarray['inform'] = $inform; $datarray['inform'] = $inform;
$datarray['verb'] = $verb; $datarray['verb'] = $verb;
$datarray['object-type'] = $objecttype;
$datarray['allow_cid'] = $str_contact_allow; $datarray['allow_cid'] = $str_contact_allow;
$datarray['allow_gid'] = $str_group_allow; $datarray['allow_gid'] = $str_group_allow;
$datarray['deny_cid'] = $str_contact_deny; $datarray['deny_cid'] = $str_contact_deny;
@ -728,8 +751,8 @@ function item_post(&$a) {
$r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, $r = q("INSERT INTO `item` (`guid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`,
`author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, `author-name`, `author-link`, `author-avatar`, `created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
`tag`, `inform`, `verb`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file` ) `tag`, `inform`, `verb`, `object-type`, `postopts`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file` )
VALUES( '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )", VALUES( '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s' )",
dbesc($datarray['guid']), dbesc($datarray['guid']),
intval($datarray['uid']), intval($datarray['uid']),
dbesc($datarray['type']), dbesc($datarray['type']),
@ -758,6 +781,7 @@ function item_post(&$a) {
dbesc($datarray['tag']), dbesc($datarray['tag']),
dbesc($datarray['inform']), dbesc($datarray['inform']),
dbesc($datarray['verb']), dbesc($datarray['verb']),
dbesc($datarray['object-type']),
dbesc($datarray['postopts']), dbesc($datarray['postopts']),
dbesc($datarray['allow_cid']), dbesc($datarray['allow_cid']),
dbesc($datarray['allow_gid']), dbesc($datarray['allow_gid']),