rename 'uri' (and parent_uri) to 'mid' (and parent_mid) since these no longer remotely resemble uri's and are actually message_id's. This change is potentially destabilising because it touches a lot of code and structure. But it has to get done and there's no better time than the present.

This commit is contained in:
friendica 2013-03-21 18:25:41 -07:00
parent b3c699d49a
commit ddf5bf8968
27 changed files with 315 additions and 284 deletions

View File

@ -17,7 +17,7 @@ require_once('include/features.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica Red'); define ( 'FRIENDICA_PLATFORM', 'Friendica Red');
define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R'); define ( 'FRIENDICA_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 ); define ( 'ZOT_REVISION', 1 );
define ( 'DB_UPDATE_VERSION', 1037 ); define ( 'DB_UPDATE_VERSION', 1038 );
define ( 'EOL', '<br />' . "\r\n" ); define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' ); define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );

View File

@ -139,9 +139,9 @@ class Item extends BaseObject {
$location = format_location($item); $location = format_location($item);
$showlike = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); $showlike = ((x($alike,$item['mid'])) ? format_like($alike[$item['mid']],$alike[$item['mid'] . '-l'],'like',$item['mid']) : '');
$showdislike = ((x($dlike,$item['uri']) && feature_enabled($conv->get_profile_owner(),'dislike')) $showdislike = ((x($dlike,$item['mid']) && feature_enabled($conv->get_profile_owner(),'dislike'))
? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : ''); ? format_like($dlike[$item['mid']],$dlike[$item['mid'] . '-l'],'dislike',$item['mid']) : '');
/* /*
* We should avoid doing this all the time, but it depends on the conversation mode * We should avoid doing this all the time, but it depends on the conversation mode

View File

@ -17,7 +17,7 @@ function profile_activity($changed, $value) {
return; return;
$arr = array(); $arr = array();
$arr['uri'] = $arr['parent_uri'] = item_message_id(); $arr['mid'] = $arr['parent_mid'] = item_message_id();
$arr['uid'] = local_user(); $arr['uid'] = local_user();
$arr['aid'] = $self['channel_account_id']; $arr['aid'] = $self['channel_account_id'];
$arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash']; $arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash'];

View File

@ -599,7 +599,7 @@ require_once('include/security.php');
if(ctype_digit($parent)) if(ctype_digit($parent))
$_REQUEST['parent'] = $parent; $_REQUEST['parent'] = $parent;
else else
$_REQUEST['parent_uri'] = $parent; $_REQUEST['parent_mid'] = $parent;
if(requestdata('lat') && requestdata('long')) if(requestdata('lat') && requestdata('long'))
$_REQUEST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long')); $_REQUEST['coord'] = sprintf("%s %s",requestdata('lat'),requestdata('long'));
@ -892,7 +892,7 @@ require_once('include/security.php');
and item_private = 0 and item_private = 0
and uid in ( " . stream_perms_api_uids() . " ) and uid in ( " . stream_perms_api_uids() . " )
$sql_extra $sql_extra
AND id > %d group by uri AND id > %d group by mid
order by received desc LIMIT %d, %d ", order by received desc LIMIT %d, %d ",
intval($since_id), intval($since_id),
intval($start), intval($start),
@ -1404,7 +1404,7 @@ require_once('include/security.php');
$status2 = array( $status2 = array(
'updated' => api_date($item['edited']), 'updated' => api_date($item['edited']),
'published' => api_date($item['created']), 'published' => api_date($item['created']),
'message_id' => $item['uri'], 'message_id' => $item['mid'],
'url' => $item['plink'], 'url' => $item['plink'],
'coordinates' => $item['coord'], 'coordinates' => $item['coord'],
'place' => $item['location'], 'place' => $item['location'],
@ -1653,10 +1653,10 @@ require_once('include/security.php');
$replyto = ''; $replyto = '';
$sub = ''; $sub = '';
if (x($_REQUEST,'replyto')) { if (x($_REQUEST,'replyto')) {
$r = q('SELECT `parent_uri`, `title` FROM `mail` WHERE `uid`=%d AND `id`=%d', $r = q('SELECT `parent_mid`, `title` FROM `mail` WHERE `uid`=%d AND `id`=%d',
intval(api_user()), intval(api_user()),
intval($_REQUEST['replyto'])); intval($_REQUEST['replyto']));
$replyto = $r[0]['parent_uri']; $replyto = $r[0]['parent_mid'];
$sub = $r[0]['title']; $sub = $r[0]['title'];
} }
else { else {
@ -1708,7 +1708,7 @@ require_once('include/security.php');
$sql_extra = "`from-url`='".dbesc( $profile_url )."'"; $sql_extra = "`from-url`='".dbesc( $profile_url )."'";
} }
elseif ($box=="conversation") { elseif ($box=="conversation") {
$sql_extra = "`parent_uri`='".dbesc( $_GET["uri"] ) ."'"; $sql_extra = "`parent_mid`='".dbesc( $_GET["uri"] ) ."'";
} }
elseif ($box=="all") { elseif ($box=="all") {
$sql_extra = "true"; $sql_extra = "true";

View File

@ -234,8 +234,8 @@ function localize_item(&$item){
if (activity_match($item['verb'],ACTIVITY_TAG)) { if (activity_match($item['verb'],ACTIVITY_TAG)) {
$r = q("SELECT * from `item`,`contact` WHERE $r = q("SELECT * from `item`,`contact` WHERE
`item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';", `item`.`contact-id`=`contact`.`id` AND `item`.`mid`='%s';",
dbesc($item['parent_uri'])); dbesc($item['parent_mid']));
if(count($r)==0) return; if(count($r)==0) return;
$obj=$r[0]; $obj=$r[0];
@ -282,7 +282,7 @@ function localize_item(&$item){
$obj = parse_xml_string($xmlhead.$item['object']); $obj = parse_xml_string($xmlhead.$item['object']);
if(strlen($obj->id)) { if(strlen($obj->id)) {
$r = q("select * from item where uri = '%s' and uid = %d limit 1", $r = q("select * from item where mid = '%s' and uid = %d limit 1",
dbesc($obj->id), dbesc($obj->id),
intval($item['uid']) intval($item['uid'])
); );
@ -634,7 +634,7 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional') {
'like' => '', 'like' => '',
'dislike' => '', 'dislike' => '',
'comment' => '', 'comment' => '',
'conv' => (($preview) ? '' : array('href'=> z_root() . '/display/' . $item['uri'], 'title'=> t('View in context'))), 'conv' => (($preview) ? '' : array('href'=> z_root() . '/display/' . $item['mid'], 'title'=> t('View in context'))),
'previewing' => $previewing, 'previewing' => $previewing,
'wait' => t('Please wait'), 'wait' => t('Please wait'),
'thread_level' => 1, 'thread_level' => 1,
@ -870,7 +870,7 @@ function like_puller($a,$item,&$arr,$mode) {
$url = zid($url); $url = zid($url);
if(! $item['thr_parent']) if(! $item['thr_parent'])
$item['thr_parent'] = $item['parent_uri']; $item['thr_parent'] = $item['parent_mid'];
if(! ((isset($arr[$item['thr_parent'] . '-l'])) && (is_array($arr[$item['thr_parent'] . '-l'])))) if(! ((isset($arr[$item['thr_parent'] . '-l'])) && (is_array($arr[$item['thr_parent'] . '-l']))))
$arr[$item['thr_parent'] . '-l'] = array(); $arr[$item['thr_parent'] . '-l'] = array();
@ -1017,12 +1017,12 @@ function get_item_children($arr, $parent) {
foreach($arr as $item) { foreach($arr as $item) {
if($item['id'] != $item['parent']) { if($item['id'] != $item['parent']) {
if(get_config('system','thread_allow')) { if(get_config('system','thread_allow')) {
// Fallback to parent_uri if thr_parent is not set // Fallback to parent_mid if thr_parent is not set
$thr_parent = $item['thr_parent']; $thr_parent = $item['thr_parent'];
if($thr_parent == '') if($thr_parent == '')
$thr_parent = $item['parent_uri']; $thr_parent = $item['parent_mid'];
if($thr_parent == $parent['uri']) { if($thr_parent == $parent['mid']) {
$item['children'] = get_item_children($arr, $item); $item['children'] = get_item_children($arr, $item);
$children[] = $item; $children[] = $item;
} }

View File

@ -260,8 +260,8 @@ function event_store($arr) {
$hash = random_string(); $hash = random_string();
if(! $arr['uri']) if(! $arr['mid'])
$arr['uri'] = item_message_id(); $arr['mid'] = item_message_id();
$r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary, `desc`,location,type, $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary, `desc`,location,type,
@ -314,8 +314,8 @@ function event_store($arr) {
$item_arr['uid'] = $arr['uid']; $item_arr['uid'] = $arr['uid'];
$item_arr['author_xchan'] = $arr['event_xchan']; $item_arr['author_xchan'] = $arr['event_xchan'];
$item_arr['uri'] = $arr['uri']; $item_arr['mid'] = $arr['mid'];
$item_arr['parent_uri'] = $arr['uri']; $item_arr['parent_mid'] = $arr['mid'];
$item_arr['item_flags'] = $item_flags; $item_arr['item_flags'] = $item_flags;

View File

@ -489,8 +489,8 @@ function get_item_elements($x) {
$arr['title'] = (($x['title']) ? htmlentities($x['title'], ENT_COMPAT,'UTF-8',false) : ''); $arr['title'] = (($x['title']) ? htmlentities($x['title'], ENT_COMPAT,'UTF-8',false) : '');
$arr['app'] = (($x['app']) ? htmlentities($x['app'], ENT_COMPAT,'UTF-8',false) : ''); $arr['app'] = (($x['app']) ? htmlentities($x['app'], ENT_COMPAT,'UTF-8',false) : '');
$arr['uri'] = (($x['message_id']) ? htmlentities($x['message_id'], ENT_COMPAT,'UTF-8',false) : ''); $arr['mid'] = (($x['message_id']) ? htmlentities($x['message_id'], ENT_COMPAT,'UTF-8',false) : '');
$arr['parent_uri'] = (($x['message_top']) ? htmlentities($x['message_top'], ENT_COMPAT,'UTF-8',false) : ''); $arr['parent_mid'] = (($x['message_top']) ? htmlentities($x['message_top'], ENT_COMPAT,'UTF-8',false) : '');
$arr['thr_parent'] = (($x['message_parent']) ? htmlentities($x['message_parent'], ENT_COMPAT,'UTF-8',false) : ''); $arr['thr_parent'] = (($x['message_parent']) ? htmlentities($x['message_parent'], ENT_COMPAT,'UTF-8',false) : '');
$arr['plink'] = (($x['permalink']) ? htmlentities($x['permalink'], ENT_COMPAT,'UTF-8',false) : ''); $arr['plink'] = (($x['permalink']) ? htmlentities($x['permalink'], ENT_COMPAT,'UTF-8',false) : '');
@ -577,7 +577,7 @@ function encode_item($item) {
if($item['item_restrict'] & ITEM_DELETED) { if($item['item_restrict'] & ITEM_DELETED) {
$x['message_id'] = $item['uri']; $x['message_id'] = $item['mid'];
$x['created'] = $item['created']; $x['created'] = $item['created'];
$x['flags'] = array('deleted'); $x['flags'] = array('deleted');
$x['owner'] = encode_item_xchan($item['owner']); $x['owner'] = encode_item_xchan($item['owner']);
@ -585,8 +585,8 @@ function encode_item($item) {
return $x; return $x;
} }
$x['message_id'] = $item['uri']; $x['message_id'] = $item['mid'];
$x['message_top'] = $item['parent_uri']; $x['message_top'] = $item['parent_mid'];
$x['message_parent'] = $item['thr_parent']; $x['message_parent'] = $item['thr_parent'];
$x['created'] = $item['created']; $x['created'] = $item['created'];
$x['edited'] = $item['edited']; $x['edited'] = $item['edited'];
@ -765,8 +765,8 @@ function encode_mail($item) {
logger('encode_mail: ' . print_r($item,true)); logger('encode_mail: ' . print_r($item,true));
$x['message_id'] = $item['uri']; $x['message_id'] = $item['mid'];
$x['message_parent'] = $item['parent_uri']; $x['message_parent'] = $item['parent_mid'];
$x['created'] = $item['created']; $x['created'] = $item['created'];
$x['title'] = $item['title']; $x['title'] = $item['title'];
$x['body'] = $item['body']; $x['body'] = $item['body'];
@ -805,8 +805,8 @@ function get_mail_elements($x) {
$arr['created'] = datetime_convert(); $arr['created'] = datetime_convert();
$arr['title'] = (($x['title']) ? htmlentities($x['title'], ENT_COMPAT,'UTF-8',false) : ''); $arr['title'] = (($x['title']) ? htmlentities($x['title'], ENT_COMPAT,'UTF-8',false) : '');
$arr['uri'] = (($x['message_id']) ? htmlentities($x['message_id'], ENT_COMPAT,'UTF-8',false) : ''); $arr['mid'] = (($x['message_id']) ? htmlentities($x['message_id'], ENT_COMPAT,'UTF-8',false) : '');
$arr['parent_uri'] = (($x['message_parent']) ? htmlentities($x['message_parent'], ENT_COMPAT,'UTF-8',false) : ''); $arr['parent_mid'] = (($x['message_parent']) ? htmlentities($x['message_parent'], ENT_COMPAT,'UTF-8',false) : '');
if(import_author_xchan($x['from'])) if(import_author_xchan($x['from']))
@ -872,7 +872,7 @@ function get_atom_elements($feed,$item) {
$res['author-name'] = unxmlify($feed->get_title()); $res['author-name'] = unxmlify($feed->get_title());
$res['author-link'] = unxmlify($feed->get_permalink()); $res['author-link'] = unxmlify($feed->get_permalink());
} }
$res['uri'] = unxmlify($item->get_id()); $res['mid'] = unxmlify($item->get_id());
$res['title'] = unxmlify($item->get_title()); $res['title'] = unxmlify($item->get_title());
$res['body'] = unxmlify($item->get_content()); $res['body'] = unxmlify($item->get_content());
$res['plink'] = unxmlify($item->get_link(0)); $res['plink'] = unxmlify($item->get_link(0));
@ -1325,7 +1325,7 @@ function item_store($arr,$force_parent = false) {
} }
$arr['aid'] = ((x($arr,'aid')) ? intval($arr['aid']) : 0); $arr['aid'] = ((x($arr,'aid')) ? intval($arr['aid']) : 0);
$arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string()); $arr['mid'] = ((x($arr,'mid')) ? notags(trim($arr['mid'])) : random_string());
$arr['author_xchan'] = ((x($arr,'author_xchan')) ? notags(trim($arr['author_xchan'])) : ''); $arr['author_xchan'] = ((x($arr,'author_xchan')) ? notags(trim($arr['author_xchan'])) : '');
$arr['owner_xchan'] = ((x($arr,'owner_xchan')) ? notags(trim($arr['owner_xchan'])) : ''); $arr['owner_xchan'] = ((x($arr,'owner_xchan')) ? notags(trim($arr['owner_xchan'])) : '');
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert()); $arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
@ -1338,7 +1338,7 @@ function item_store($arr,$force_parent = false) {
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : ''); $arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
$arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : ''); $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : '');
$arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : ''); $arr['coord'] = ((x($arr,'coord')) ? notags(trim($arr['coord'])) : '');
$arr['parent_uri'] = ((x($arr,'parent_uri')) ? notags(trim($arr['parent_uri'])) : ''); $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : '');
$arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : ''); $arr['verb'] = ((x($arr,'verb')) ? notags(trim($arr['verb'])) : '');
$arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : ''); $arr['obj_type'] = ((x($arr,'obj_type')) ? notags(trim($arr['obj_type'])) : '');
$arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : ''); $arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : '');
@ -1358,14 +1358,14 @@ function item_store($arr,$force_parent = false) {
$arr['item_flags'] = $arr['item_flags'] | ITEM_UNSEEN; $arr['item_flags'] = $arr['item_flags'] | ITEM_UNSEEN;
$arr['thr_parent'] = $arr['parent_uri']; $arr['thr_parent'] = $arr['parent_mid'];
$arr['llink'] = z_root() . '/display/' . $arr['uri']; $arr['llink'] = z_root() . '/display/' . $arr['mid'];
if(! $arr['plink']) if(! $arr['plink'])
$arr['plink'] = $arr['llink']; $arr['plink'] = $arr['llink'];
if($arr['parent_uri'] === $arr['uri']) { if($arr['parent_mid'] === $arr['mid']) {
$parent_id = 0; $parent_id = 0;
$parent_deleted = 0; $parent_deleted = 0;
$allow_cid = $arr['allow_cid']; $allow_cid = $arr['allow_cid'];
@ -1379,8 +1379,8 @@ function item_store($arr,$force_parent = false) {
// find the parent and snarf the item id and ACL's // find the parent and snarf the item id and ACL's
// and anything else we need to inherit // and anything else we need to inherit
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", $r = q("SELECT * FROM `item` WHERE `mid` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1",
dbesc($arr['parent_uri']), dbesc($arr['parent_mid']),
intval($arr['uid']) intval($arr['uid'])
); );
@ -1390,12 +1390,12 @@ function item_store($arr,$force_parent = false) {
// even though we don't support it now, preserve the info // even though we don't support it now, preserve the info
// and re-attach to the conversation parent. // and re-attach to the conversation parent.
if($r[0]['uri'] != $r[0]['parent_uri']) { if($r[0]['mid'] != $r[0]['parent_mid']) {
$arr['parent_uri'] = $r[0]['parent_uri']; $arr['parent_mid'] = $r[0]['parent_mid'];
$z = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `parent_uri` = '%s' AND `uid` = %d $z = q("SELECT * FROM `item` WHERE `mid` = '%s' AND `parent_mid` = '%s' AND `uid` = %d
ORDER BY `id` ASC LIMIT 1", ORDER BY `id` ASC LIMIT 1",
dbesc($r[0]['parent_uri']), dbesc($r[0]['parent_mid']),
dbesc($r[0]['parent_uri']), dbesc($r[0]['parent_mid']),
intval($arr['uid']) intval($arr['uid'])
); );
if($z && count($z)) if($z && count($z))
@ -1434,7 +1434,7 @@ function item_store($arr,$force_parent = false) {
if($force_parent) { if($force_parent) {
logger('item_store: $force_parent=true, reply converted to top-level post.'); logger('item_store: $force_parent=true, reply converted to top-level post.');
$parent_id = 0; $parent_id = 0;
$arr['parent_uri'] = $arr['uri']; $arr['parent_mid'] = $arr['mid'];
$arr['flags'] = $arr['flags'] | ITEM_THREAD_TOP; $arr['flags'] = $arr['flags'] | ITEM_THREAD_TOP;
} }
else { else {
@ -1450,8 +1450,8 @@ function item_store($arr,$force_parent = false) {
$arr['item_restrict'] = $arr['item_restrict'] | ITEM_DELETED; $arr['item_restrict'] = $arr['item_restrict'] | ITEM_DELETED;
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($arr['uri']), dbesc($arr['mid']),
intval($arr['uid']) intval($arr['uid'])
); );
if($r) { if($r) {
@ -1486,8 +1486,8 @@ function item_store($arr,$force_parent = false) {
// find the item we just created // find the item we just created
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC ", $r = q("SELECT `id` FROM `item` WHERE `mid` = '%s' AND `uid` = %d ORDER BY `id` ASC ",
$arr['uri'], // already dbesc'd $arr['mid'], // already dbesc'd
intval($arr['uid']) intval($arr['uid'])
); );
@ -1501,14 +1501,14 @@ function item_store($arr,$force_parent = false) {
} }
if(count($r) > 1) { if(count($r) > 1) {
logger('item_store: duplicated post occurred. Removing duplicates.'); logger('item_store: duplicated post occurred. Removing duplicates.');
q("DELETE FROM `item` WHERE `uri` = '%s' AND `uid` = %d AND `id` != %d ", q("DELETE FROM `item` WHERE `mid` = '%s' AND `uid` = %d AND `id` != %d ",
$arr['uri'], $arr['mid'],
intval($arr['uid']), intval($arr['uid']),
intval($current_post) intval($current_post)
); );
} }
if((! $parent_id) || ($arr['parent_uri'] === $arr['uri'])) if((! $parent_id) || ($arr['parent_mid'] === $arr['mid']))
$parent_id = $current_post; $parent_id = $current_post;
if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid))
@ -1636,9 +1636,9 @@ function item_store_update($arr,$force_parent = false) {
} }
unset($arr['aid']); unset($arr['aid']);
unset($arr['uri']); unset($arr['mid']);
unset($arr['parent']); unset($arr['parent']);
unset($arr['parent_uri']); unset($arr['parent_mid']);
unset($arr['created']); unset($arr['created']);
unset($arr['author_xchan']); unset($arr['author_xchan']);
unset($arr['owner_xchan']); unset($arr['owner_xchan']);
@ -1762,8 +1762,8 @@ function send_status_notifications($post_id,$item) {
// Was I involved in this conversation? // Was I involved in this conversation?
$x = q("select * from item where parent_uri = '%s' and uid = %d", $x = q("select * from item where parent_mid = '%s' and uid = %d",
dbesc($item['parent_uri']), dbesc($item['parent_mid']),
intval($item['uid']) intval($item['uid'])
); );
if($x) { if($x) {
@ -1785,11 +1785,11 @@ function send_status_notifications($post_id,$item) {
'from_xchan' => $item['author_xchan'], 'from_xchan' => $item['author_xchan'],
'to_xchan' => $r[0]['channel_hash'], 'to_xchan' => $r[0]['channel_hash'],
'item' => $item, 'item' => $item,
'link' => get_app()->get_baseurl() . '/display/' . $item['uri'], 'link' => get_app()->get_baseurl() . '/display/' . $item['mid'],
'verb' => ACTIVITY_POST, 'verb' => ACTIVITY_POST,
'otype' => 'item', 'otype' => 'item',
'parent' => $parent, 'parent' => $parent,
'parent_uri' => $item['parent_uri'] 'parent_mid' => $item['parent_mid']
)); ));
return; return;
} }
@ -1939,7 +1939,7 @@ function tgroup_check($uid,$item) {
// check that the message originated elsewhere and is a top-level post // check that the message originated elsewhere and is a top-level post
if(($item['wall']) || ($item['origin']) || ($item['uri'] != $item['parent-uri'])) if(($item['wall']) || ($item['origin']) || ($item['mid'] != $item['parent-mid']))
return false; return false;
@ -1996,23 +1996,23 @@ function mail_store($arr) {
$arr['body'] = escape_tags($arr['body']); $arr['body'] = escape_tags($arr['body']);
$arr['account_id'] = ((x($arr,'account_id')) ? intval($arr['account_id']) : 0); $arr['account_id'] = ((x($arr,'account_id')) ? intval($arr['account_id']) : 0);
$arr['uri'] = ((x($arr,'uri')) ? notags(trim($arr['uri'])) : random_string()); $arr['mid'] = ((x($arr,'mid')) ? notags(trim($arr['mid'])) : random_string());
$arr['from_xchan'] = ((x($arr,'from_xchan')) ? notags(trim($arr['from_xchan'])) : ''); $arr['from_xchan'] = ((x($arr,'from_xchan')) ? notags(trim($arr['from_xchan'])) : '');
$arr['to_xchan'] = ((x($arr,'to_xchan')) ? notags(trim($arr['to_xchan'])) : ''); $arr['to_xchan'] = ((x($arr,'to_xchan')) ? notags(trim($arr['to_xchan'])) : '');
$arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert()); $arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert());
$arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : ''); $arr['title'] = ((x($arr,'title')) ? notags(trim($arr['title'])) : '');
$arr['parent_uri'] = ((x($arr,'parent_uri')) ? notags(trim($arr['parent_uri'])) : ''); $arr['parent_mid'] = ((x($arr,'parent_mid')) ? notags(trim($arr['parent_mid'])) : '');
$arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : '');
$arr['mail_flags'] = ((x($arr,'mail_flags')) ? intval($arr['mail_flags']) : 0 ); $arr['mail_flags'] = ((x($arr,'mail_flags')) ? intval($arr['mail_flags']) : 0 );
if(! $arr['parent_uri']) { if(! $arr['parent_mid']) {
logger('mail_store: missing parent'); logger('mail_store: missing parent');
$arr['parent_uri'] = $arr['uri']; $arr['parent_mid'] = $arr['mid'];
} }
$r = q("SELECT `id` FROM mail WHERE `uri` = '%s' AND channel_id = %d LIMIT 1", $r = q("SELECT `id` FROM mail WHERE `mid` = '%s' AND channel_id = %d LIMIT 1",
dbesc($arr['uri']), dbesc($arr['mid']),
intval($arr['channel_id']) intval($arr['channel_id'])
); );
if($r) { if($r) {
@ -2039,8 +2039,8 @@ function mail_store($arr) {
// find the item we just created // find the item we just created
$r = q("SELECT `id` FROM mail WHERE `uri` = '%s' AND `channel_id` = %d ORDER BY `id` ASC ", $r = q("SELECT `id` FROM mail WHERE `mid` = '%s' AND `channel_id` = %d ORDER BY `id` ASC ",
$arr['uri'], // already dbesc'd $arr['mid'], // already dbesc'd
intval($arr['channel_id']) intval($arr['channel_id'])
); );
@ -2055,8 +2055,8 @@ function mail_store($arr) {
} }
if(count($r) > 1) { if(count($r) > 1) {
logger('mail_store: duplicated post occurred. Removing duplicates.'); logger('mail_store: duplicated post occurred. Removing duplicates.');
q("DELETE FROM mail WHERE `uri` = '%s' AND `channel_id` = %d AND `id` != %d ", q("DELETE FROM mail WHERE `mid` = '%s' AND `channel_id` = %d AND `id` != %d ",
$arr['uri'], $arr['mid'],
intval($arr['channel_id']), intval($arr['channel_id']),
intval($current_post) intval($current_post)
); );
@ -2509,7 +2509,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
foreach($del_entries as $dentry) { foreach($del_entries as $dentry) {
$deleted = false; $deleted = false;
if(isset($dentry['attribs']['']['ref'])) { if(isset($dentry['attribs']['']['ref'])) {
$uri = $dentry['attribs']['']['ref']; $mid = $dentry['attribs']['']['ref'];
$deleted = true; $deleted = true;
if(isset($dentry['attribs']['']['when'])) { if(isset($dentry['attribs']['']['when'])) {
$when = $dentry['attribs']['']['when']; $when = $dentry['attribs']['']['when'];
@ -2520,8 +2520,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
} }
if($deleted && is_array($contact)) { if($deleted && is_array($contact)) {
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id` $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join `contact` on `item`.`contact-id` = `contact`.`id`
WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1", WHERE `mid` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
dbesc($uri), dbesc($mid),
intval($importer['uid']), intval($importer['uid']),
intval($contact['id']) intval($contact['id'])
); );
@ -2529,13 +2529,13 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$item = $r[0]; $item = $r[0];
if(! $item['deleted']) if(! $item['deleted'])
logger('consume_feed: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG); logger('consume_feed: deleting item ' . $item['id'] . ' mid=' . $item['mid'], LOGGER_DEBUG);
if(($item['verb'] === ACTIVITY_TAG) && ($item['obj_type'] === ACTIVITY_OBJ_TAGTERM)) { if(($item['verb'] === ACTIVITY_TAG) && ($item['obj_type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false); $xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false); $xt = parse_xml_string($item['target'],false);
if($xt->type === ACTIVITY_OBJ_NOTE) { if($xt->type === ACTIVITY_OBJ_NOTE) {
$i = q("select * from `item` where uri = '%s' and uid = %d limit 1", $i = q("select * from `item` where mid = '%s' and uid = %d limit 1",
dbesc($xt->id), dbesc($xt->id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -2566,23 +2566,23 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
} }
} }
if($item['uri'] == $item['parent_uri']) { if($item['mid'] == $item['parent_mid']) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
`body` = '', `title` = '' `body` = '', `title` = ''
WHERE `parent_uri` = '%s' AND `uid` = %d", WHERE `parent_mid` = '%s' AND `uid` = %d",
dbesc($when), dbesc($when),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($item['uri']), dbesc($item['mid']),
intval($importer['uid']) intval($importer['uid'])
); );
} }
else { else {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
`body` = '', `title` = '' `body` = '', `title` = ''
WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($when), dbesc($when),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($uri), dbesc($mid),
intval($importer['uid']) intval($importer['uid'])
); );
} }
@ -2611,7 +2611,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$rawthread = $item->get_item_tags( NAMESPACE_THREAD,'in-reply-to'); $rawthread = $item->get_item_tags( NAMESPACE_THREAD,'in-reply-to');
if(isset($rawthread[0]['attribs']['']['ref'])) { if(isset($rawthread[0]['attribs']['']['ref'])) {
$is_reply = true; $is_reply = true;
$parent_uri = $rawthread[0]['attribs']['']['ref']; $parent_mid = $rawthread[0]['attribs']['']['ref'];
} }
if(($is_reply) && is_array($contact)) { if(($is_reply) && is_array($contact)) {
@ -2643,7 +2643,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
} }
$r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
@ -2657,7 +2657,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
continue; continue;
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
@ -2670,19 +2670,19 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
} }
$datarray['parent_uri'] = $parent_uri; $datarray['parent_mid'] = $parent_mid;
$datarray['uid'] = $importer['uid']; $datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id']; $datarray['contact-id'] = $contact['id'];
if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) { if((activity_match($datarray['verb'],ACTIVITY_LIKE)) || (activity_match($datarray['verb'],ACTIVITY_DISLIKE))) {
$datarray['type'] = 'activity'; $datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE; $datarray['gravity'] = GRAVITY_LIKE;
// only one like or dislike per person // only one like or dislike per person
$r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent_uri` = '%s' OR `thr_parent` = '%s') limit 1", $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent_mid` = '%s' OR `thr_parent` = '%s') limit 1",
intval($datarray['uid']), intval($datarray['uid']),
intval($datarray['contact-id']), intval($datarray['contact-id']),
dbesc($datarray['verb']), dbesc($datarray['verb']),
dbesc($parent_uri), dbesc($parent_mid),
dbesc($parent_uri) dbesc($parent_mid)
); );
if($r && count($r)) if($r && count($r))
continue; continue;
@ -2693,7 +2693,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$xt = parse_xml_string($datarray['target'],false); $xt = parse_xml_string($datarray['target'],false);
if($xt->type == ACTIVITY_OBJ_NOTE) { if($xt->type == ACTIVITY_OBJ_NOTE) {
$r = q("select * from item where `uri` = '%s' AND `uid` = %d limit 1", $r = q("select * from item where `mid` = '%s' AND `uid` = %d limit 1",
dbesc($xt->id), dbesc($xt->id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -2745,13 +2745,13 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$ev = bbtoevent($datarray['body']); $ev = bbtoevent($datarray['body']);
if(x($ev,'desc') && x($ev,'start')) { if(x($ev,'desc') && x($ev,'start')) {
$ev['uid'] = $importer['uid']; $ev['uid'] = $importer['uid'];
$ev['uri'] = $item_id; $ev['mid'] = $item_id;
$ev['edited'] = $datarray['edited']; $ev['edited'] = $datarray['edited'];
$ev['private'] = $datarray['private']; $ev['private'] = $datarray['private'];
if(is_array($contact)) if(is_array($contact))
$ev['cid'] = $contact['id']; $ev['cid'] = $contact['id'];
$r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `event` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
@ -2762,7 +2762,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
} }
} }
$r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
@ -2776,7 +2776,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
continue; continue;
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
@ -2820,7 +2820,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$datarray['wall'] = 1; $datarray['wall'] = 1;
} }
$datarray['parent_uri'] = $item_id; $datarray['parent_mid'] = $item_id;
$datarray['uid'] = $importer['uid']; $datarray['uid'] = $importer['uid'];
$datarray['contact-id'] = $contact['id']; $datarray['contact-id'] = $contact['id'];
@ -3129,8 +3129,8 @@ function local_delivery($importer,$data) {
$msg['body'] = escape_tags(unxmlify($base['content'][0]['data'])); $msg['body'] = escape_tags(unxmlify($base['content'][0]['data']));
$msg['seen'] = 0; $msg['seen'] = 0;
$msg['replied'] = 0; $msg['replied'] = 0;
$msg['uri'] = notags(unxmlify($base['id'][0]['data'])); $msg['mid'] = notags(unxmlify($base['id'][0]['data']));
$msg['parent_uri'] = notags(unxmlify($base['in-reply-to'][0]['data'])); $msg['parent_mid'] = notags(unxmlify($base['in-reply-to'][0]['data']));
$msg['created'] = datetime_convert(notags(unxmlify('UTC','UTC',$base['sentdate'][0]['data']))); $msg['created'] = datetime_convert(notags(unxmlify('UTC','UTC',$base['sentdate'][0]['data'])));
dbesc_array($msg); dbesc_array($msg);
@ -3185,7 +3185,7 @@ function local_delivery($importer,$data) {
foreach($del_entries as $dentry) { foreach($del_entries as $dentry) {
$deleted = false; $deleted = false;
if(isset($dentry['attribs']['']['ref'])) { if(isset($dentry['attribs']['']['ref'])) {
$uri = $dentry['attribs']['']['ref']; $mid = $dentry['attribs']['']['ref'];
$deleted = true; $deleted = true;
if(isset($dentry['attribs']['']['when'])) { if(isset($dentry['attribs']['']['when'])) {
$when = $dentry['attribs']['']['when']; $when = $dentry['attribs']['']['when'];
@ -3199,12 +3199,12 @@ function local_delivery($importer,$data) {
// check for relayed deletes to our conversation // check for relayed deletes to our conversation
$is_reply = false; $is_reply = false;
$r = q("select * from item where uri = '%s' and uid = %d limit 1", $r = q("select * from item where mid = '%s' and uid = %d limit 1",
dbesc($uri), dbesc($mid),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
if(count($r)) { if(count($r)) {
$parent_uri = $r[0]['parent_uri']; $parent_mid = $r[0]['parent_mid'];
if($r[0]['id'] != $r[0]['parent']) if($r[0]['id'] != $r[0]['parent'])
$is_reply = true; $is_reply = true;
} }
@ -3225,16 +3225,16 @@ function local_delivery($importer,$data) {
$is_a_remote_delete = false; $is_a_remote_delete = false;
$r = q("select `item`.`id`, `item`.`uri`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`, $r = q("select `item`.`id`, `item`.`mid`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uri` = '%s' AND (`item`.`parent_uri` = '%s' or `item`.`thr_parent` = '%s') WHERE `item`.`mid` = '%s' AND (`item`.`parent_mid` = '%s' or `item`.`thr_parent` = '%s')
AND `item`.`uid` = %d AND `item`.`uid` = %d
$sql_extra $sql_extra
LIMIT 1", LIMIT 1",
dbesc($parent_uri), dbesc($parent_mid),
dbesc($parent_uri), dbesc($parent_mid),
dbesc($parent_uri), dbesc($parent_mid),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
if($r && count($r)) if($r && count($r))
@ -3258,8 +3258,8 @@ function local_delivery($importer,$data) {
} }
$r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join contact on `item`.`contact-id` = `contact`.`id` $r = q("SELECT `item`.*, `contact`.`self` FROM `item` left join contact on `item`.`contact-id` = `contact`.`id`
WHERE `uri` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1", WHERE `mid` = '%s' AND `item`.`uid` = %d AND `contact-id` = %d AND NOT `item`.`file` LIKE '%%[%%' LIMIT 1",
dbesc($uri), dbesc($mid),
intval($importer['importer_uid']), intval($importer['importer_uid']),
intval($importer['id']) intval($importer['id'])
); );
@ -3270,14 +3270,14 @@ function local_delivery($importer,$data) {
if($item['deleted']) if($item['deleted'])
continue; continue;
logger('local_delivery: deleting item ' . $item['id'] . ' uri=' . $item['uri'], LOGGER_DEBUG); logger('local_delivery: deleting item ' . $item['id'] . ' mid=' . $item['mid'], LOGGER_DEBUG);
if(($item['verb'] === ACTIVITY_TAG) && ($item['obj_type'] === ACTIVITY_OBJ_TAGTERM)) { if(($item['verb'] === ACTIVITY_TAG) && ($item['obj_type'] === ACTIVITY_OBJ_TAGTERM)) {
$xo = parse_xml_string($item['object'],false); $xo = parse_xml_string($item['object'],false);
$xt = parse_xml_string($item['target'],false); $xt = parse_xml_string($item['target'],false);
if($xt->type === ACTIVITY_OBJ_NOTE) { if($xt->type === ACTIVITY_OBJ_NOTE) {
$i = q("select * from `item` where uri = '%s' and uid = %d limit 1", $i = q("select * from `item` where mid = '%s' and uid = %d limit 1",
dbesc($xt->id), dbesc($xt->id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3309,23 +3309,23 @@ function local_delivery($importer,$data) {
} }
} }
if($item['uri'] == $item['parent_uri']) { if($item['mid'] == $item['parent_mid']) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
`body` = '', `title` = '' `body` = '', `title` = ''
WHERE `parent_uri` = '%s' AND `uid` = %d", WHERE `parent_mid` = '%s' AND `uid` = %d",
dbesc($when), dbesc($when),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($item['uri']), dbesc($item['mid']),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
} }
else { else {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
`body` = '', `title` = '' `body` = '', `title` = ''
WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($when), dbesc($when),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($uri), dbesc($mid),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3347,7 +3347,7 @@ function local_delivery($importer,$data) {
$rawthread = $item->get_item_tags( NAMESPACE_THREAD, 'in-reply-to'); $rawthread = $item->get_item_tags( NAMESPACE_THREAD, 'in-reply-to');
if(isset($rawthread[0]['attribs']['']['ref'])) { if(isset($rawthread[0]['attribs']['']['ref'])) {
$is_reply = true; $is_reply = true;
$parent_uri = $rawthread[0]['attribs']['']['ref']; $parent_mid = $rawthread[0]['attribs']['']['ref'];
} }
if($is_reply) { if($is_reply) {
@ -3367,16 +3367,16 @@ function local_delivery($importer,$data) {
$is_a_remote_comment = false; $is_a_remote_comment = false;
// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used? // POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
$r = q("select `item`.`id`, `item`.`uri`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`, $r = q("select `item`.`id`, `item`.`mid`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item` `contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uri` = '%s' AND (`item`.`parent_uri` = '%s' or `item`.`thr_parent` = '%s') WHERE `item`.`mid` = '%s' AND (`item`.`parent_mid` = '%s' or `item`.`thr_parent` = '%s')
AND `item`.`uid` = %d AND `item`.`uid` = %d
$sql_extra $sql_extra
LIMIT 1", LIMIT 1",
dbesc($parent_uri), dbesc($parent_mid),
dbesc($parent_uri), dbesc($parent_mid),
dbesc($parent_uri), dbesc($parent_mid),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
if($r && count($r)) if($r && count($r))
@ -3401,7 +3401,7 @@ function local_delivery($importer,$data) {
$datarray = get_atom_elements($feed,$item); $datarray = get_atom_elements($feed,$item);
$r = q("SELECT `id`, `uid`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `id`, `uid`, `edited`, `body` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), dbesc($item_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3417,7 +3417,7 @@ function local_delivery($importer,$data) {
continue; continue;
logger('received updated comment' , LOGGER_DEBUG); logger('received updated comment' , LOGGER_DEBUG);
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
@ -3441,7 +3441,7 @@ function local_delivery($importer,$data) {
$datarray['type'] = 'remote-comment'; $datarray['type'] = 'remote-comment';
$datarray['wall'] = 1; $datarray['wall'] = 1;
$datarray['parent_uri'] = $parent_uri; $datarray['parent_mid'] = $parent_mid;
$datarray['uid'] = $importer['importer_uid']; $datarray['uid'] = $importer['importer_uid'];
$datarray['owner-name'] = $own[0]['name']; $datarray['owner-name'] = $own[0]['name'];
$datarray['owner-link'] = $own[0]['url']; $datarray['owner-link'] = $own[0]['url'];
@ -3454,12 +3454,12 @@ function local_delivery($importer,$data) {
$datarray['gravity'] = GRAVITY_LIKE; $datarray['gravity'] = GRAVITY_LIKE;
// only one like or dislike per person // only one like or dislike per person
$r = q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`thr_parent` = '%s' or `parent_uri` = '%s') and deleted = 0 limit 1", $r = q("select id from item where uid = %d and `contact-id` = %d and verb = '%s' and (`thr_parent` = '%s' or `parent_mid` = '%s') and deleted = 0 limit 1",
intval($datarray['uid']), intval($datarray['uid']),
intval($datarray['contact-id']), intval($datarray['contact-id']),
dbesc($datarray['verb']), dbesc($datarray['verb']),
dbesc($datarray['parent_uri']), dbesc($datarray['parent_mid']),
dbesc($datarray['parent_uri']) dbesc($datarray['parent_mid'])
); );
if($r && count($r)) if($r && count($r))
@ -3475,7 +3475,7 @@ function local_delivery($importer,$data) {
// fetch the parent item // fetch the parent item
$tagp = q("select * from item where uri = '%s' and uid = %d limit 1", $tagp = q("select * from item where mid = '%s' and uid = %d limit 1",
dbesc($xt->id), dbesc($xt->id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3507,13 +3507,13 @@ function local_delivery($importer,$data) {
$parent = 0; $parent = 0;
if($posted_id) { if($posted_id) {
$r = q("SELECT `parent`, `parent_uri` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT `parent`, `parent_mid` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($posted_id), intval($posted_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
if(count($r)) { if(count($r)) {
$parent = $r[0]['parent']; $parent = $r[0]['parent'];
$parent_uri = $r[0]['parent_uri']; $parent_mid = $r[0]['parent_mid'];
} }
if(! $is_like) { if(! $is_like) {
@ -3554,7 +3554,7 @@ function local_delivery($importer,$data) {
'verb' => ACTIVITY_POST, 'verb' => ACTIVITY_POST,
'otype' => 'item', 'otype' => 'item',
'parent' => $parent, 'parent' => $parent,
'parent_uri' => $parent_uri, 'parent_mid' => $parent_mid,
)); ));
} }
@ -3575,7 +3575,7 @@ function local_delivery($importer,$data) {
continue; continue;
$r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), dbesc($item_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3589,7 +3589,7 @@ function local_delivery($importer,$data) {
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
continue; continue;
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
@ -3601,19 +3601,19 @@ function local_delivery($importer,$data) {
continue; continue;
} }
$datarray['parent_uri'] = $parent_uri; $datarray['parent_mid'] = $parent_mid;
$datarray['uid'] = $importer['importer_uid']; $datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id']; $datarray['contact-id'] = $importer['id'];
if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) { if(($datarray['verb'] == ACTIVITY_LIKE) || ($datarray['verb'] == ACTIVITY_DISLIKE)) {
$datarray['type'] = 'activity'; $datarray['type'] = 'activity';
$datarray['gravity'] = GRAVITY_LIKE; $datarray['gravity'] = GRAVITY_LIKE;
// only one like or dislike per person // only one like or dislike per person
$r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent_uri` = '%s' OR `thr_parent` = '%s') limit 1", $r = q("select id from item where uid = %d and `contact-id` = %d and verb ='%s' and deleted = 0 and (`parent_mid` = '%s' OR `thr_parent` = '%s') limit 1",
intval($datarray['uid']), intval($datarray['uid']),
intval($datarray['contact-id']), intval($datarray['contact-id']),
dbesc($datarray['verb']), dbesc($datarray['verb']),
dbesc($parent_uri), dbesc($parent_mid),
dbesc($parent_uri) dbesc($parent_mid)
); );
if($r && count($r)) if($r && count($r))
continue; continue;
@ -3626,7 +3626,7 @@ function local_delivery($importer,$data) {
$xt = parse_xml_string($datarray['target'],false); $xt = parse_xml_string($datarray['target'],false);
if($xt->type == ACTIVITY_OBJ_NOTE) { if($xt->type == ACTIVITY_OBJ_NOTE) {
$r = q("select * from item where `uri` = '%s' AND `uid` = %d limit 1", $r = q("select * from item where `mid` = '%s' AND `uid` = %d limit 1",
dbesc($xt->id), dbesc($xt->id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3651,8 +3651,8 @@ function local_delivery($importer,$data) {
if(!x($datarray['type']) || $datarray['type'] != 'activity') { if(!x($datarray['type']) || $datarray['type'] != 'activity') {
$myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent_uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0", $myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent_mid` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
dbesc($parent_uri), dbesc($parent_mid),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3690,7 +3690,7 @@ function local_delivery($importer,$data) {
'verb' => ACTIVITY_POST, 'verb' => ACTIVITY_POST,
'otype' => 'item', 'otype' => 'item',
'parent' => $conv_parent, 'parent' => $conv_parent,
'parent_uri' => $parent_uri 'parent_mid' => $parent_mid
)); ));
@ -3717,11 +3717,11 @@ function local_delivery($importer,$data) {
if(x($ev,'desc') && x($ev,'start')) { if(x($ev,'desc') && x($ev,'start')) {
$ev['cid'] = $importer['id']; $ev['cid'] = $importer['id'];
$ev['uid'] = $importer['uid']; $ev['uid'] = $importer['uid'];
$ev['uri'] = $item_id; $ev['mid'] = $item_id;
$ev['edited'] = $datarray['edited']; $ev['edited'] = $datarray['edited'];
$ev['private'] = $datarray['private']; $ev['private'] = $datarray['private'];
$r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `event` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), dbesc($item_id),
intval($importer['uid']) intval($importer['uid'])
); );
@ -3732,7 +3732,7 @@ function local_delivery($importer,$data) {
} }
} }
$r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT `uid`, `edited`, `body` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($item_id), dbesc($item_id),
intval($importer['importer_uid']) intval($importer['importer_uid'])
); );
@ -3746,7 +3746,7 @@ function local_delivery($importer,$data) {
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited']) if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
continue; continue;
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `edited` = '%s' WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($datarray['title']), dbesc($datarray['title']),
dbesc($datarray['body']), dbesc($datarray['body']),
dbesc(datetime_convert('UTC','UTC',$datarray['edited'])), dbesc(datetime_convert('UTC','UTC',$datarray['edited'])),
@ -3764,7 +3764,7 @@ function local_delivery($importer,$data) {
if($importer['remote_self']) if($importer['remote_self'])
$datarray['wall'] = 1; $datarray['wall'] = 1;
$datarray['parent_uri'] = $item_id; $datarray['parent_mid'] = $item_id;
$datarray['uid'] = $importer['importer_uid']; $datarray['uid'] = $importer['importer_uid'];
$datarray['contact-id'] = $importer['id']; $datarray['contact-id'] = $importer['id'];
@ -3992,7 +3992,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
return; return;
if($item['deleted']) if($item['deleted'])
return '<at:deleted-entry ref="' . xmlify($item['uri']) . '" when="' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '" />' . "\r\n"; return '<at:deleted-entry ref="' . xmlify($item['mid']) . '" when="' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '" />' . "\r\n";
if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid']) if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid'])
@ -4010,12 +4010,12 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
if(strlen($item['owner-name'])) if(strlen($item['owner-name']))
$o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']); $o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']);
if(($item['parent'] != $item['id']) || ($item['parent_uri'] !== $item['uri']) || (($item['thr_parent'] !== '') && ($item['thr_parent'] !== $item['uri']))) { if(($item['parent'] != $item['id']) || ($item['parent_mid'] !== $item['mid']) || (($item['thr_parent'] !== '') && ($item['thr_parent'] !== $item['mid']))) {
$parent_item = (($item['thr_parent']) ? $item['thr_parent'] : $item['parent_uri']); $parent_item = (($item['thr_parent']) ? $item['thr_parent'] : $item['parent_mid']);
$o .= '<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['parent']) . '" />' . "\r\n"; $o .= '<thr:in-reply-to ref="' . xmlify($parent_item) . '" type="text/html" href="' . xmlify($a->get_baseurl() . '/display/' . $owner['nickname'] . '/' . $item['parent']) . '" />' . "\r\n";
} }
$o .= '<id>' . xmlify($item['uri']) . '</id>' . "\r\n"; $o .= '<id>' . xmlify($item['mid']) . '</id>' . "\r\n";
$o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n"; $o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n";
$o .= '<published>' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '</published>' . "\r\n"; $o .= '<published>' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '</published>' . "\r\n";
$o .= '<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>' . "\r\n"; $o .= '<updated>' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '</updated>' . "\r\n";

View File

@ -43,21 +43,21 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
$dups = false; $dups = false;
$hash = random_string(); $hash = random_string();
$uri = $hash . '@' . get_app()->get_hostname(); $mid = $hash . '@' . get_app()->get_hostname();
$r = q("SELECT id FROM mail WHERE uri = '%s' LIMIT 1", $r = q("SELECT id FROM mail WHERE mid = '%s' LIMIT 1",
dbesc($uri)); dbesc($mid));
if(count($r)) if(count($r))
$dups = true; $dups = true;
} while($dups == true); } while($dups == true);
if(! strlen($replyto)) { if(! strlen($replyto)) {
$replyto = $uri; $replyto = $mid;
} }
$r = q("INSERT INTO mail ( account_id, channel_id, from_xchan, to_xchan, title, body, uri, parent_uri, created ) $r = q("INSERT INTO mail ( account_id, channel_id, from_xchan, to_xchan, title, body, mid, parent_mid, created )
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s' )",
intval($channel['channel_account_id']), intval($channel['channel_account_id']),
intval($channel['channel_id']), intval($channel['channel_id']),
@ -65,15 +65,15 @@ function send_message($uid = 0, $recipient='', $body='', $subject='', $replyto='
dbesc($recipient), dbesc($recipient),
dbesc($subject), dbesc($subject),
dbesc($body), dbesc($body),
dbesc($uri), dbesc($mid),
dbesc($replyto), dbesc($replyto),
dbesc(datetime_convert()) dbesc(datetime_convert())
); );
// verify the save // verify the save
$r = q("SELECT * FROM mail WHERE uri = '%s' and channel_id = %d LIMIT 1", $r = q("SELECT * FROM mail WHERE mid = '%s' and channel_id = %d LIMIT 1",
dbesc($uri), dbesc($mid),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
if($r) if($r)
@ -221,13 +221,13 @@ function private_messages_drop($channel_id, $messageitem_id, $drop_conversation
if($drop_conversation) { if($drop_conversation) {
// find the parent_id // find the parent_id
$p = q("SELECT parent_uri FROM mail WHERE id = %d AND channel_id = %d LIMIT 1", $p = q("SELECT parent_mid FROM mail WHERE id = %d AND channel_id = %d LIMIT 1",
intval($messageitem_id), intval($messageitem_id),
intval($channel_id) intval($channel_id)
); );
if($p) { if($p) {
$r = q("DELETE FROM mail WHERE parent_uri = '%s' AND channel_id = %d ", $r = q("DELETE FROM mail WHERE parent_mid = '%s' AND channel_id = %d ",
dbesc($p[0]['parent_uri']), dbesc($p[0]['parent_mid']),
intval($channel_id) intval($channel_id)
); );
if($r) if($r)
@ -248,9 +248,9 @@ function private_messages_drop($channel_id, $messageitem_id, $drop_conversation
function private_messages_fetch_conversation($channel_id, $messageitem_id, $updateseen = false) { function private_messages_fetch_conversation($channel_id, $messageitem_id, $updateseen = false) {
// find the parent_uri of the message being requested // find the parent_mid of the message being requested
$r = q("SELECT parent_uri from mail WHERE channel_id = %d and id = %d limit 1", $r = q("SELECT parent_mid from mail WHERE channel_id = %d and id = %d limit 1",
intval($channel_id), intval($channel_id),
intval($messageitem_id) intval($messageitem_id)
); );
@ -258,8 +258,8 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda
if(! $r) if(! $r)
return array(); return array();
$messages = q("select * from mail where parent_uri = '%s' and channel_id = %d order by created asc", $messages = q("select * from mail where parent_mid = '%s' and channel_id = %d order by created asc",
dbesc($r[0]['parent_uri']), dbesc($r[0]['parent_mid']),
intval($channel_id) intval($channel_id)
); );
@ -286,10 +286,10 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda
if($updateseen) { if($updateseen) {
$r = q("UPDATE `mail` SET mail_flags = (mail_flags ^ %d) where not (mail_flags & %d) and parent_uri = '%s' AND channel_id = %d", $r = q("UPDATE `mail` SET mail_flags = (mail_flags ^ %d) where not (mail_flags & %d) and parent_mid = '%s' AND channel_id = %d",
intval(MAIL_SEEN), intval(MAIL_SEEN),
intval(MAIL_SEEN), intval(MAIL_SEEN),
dbesc($r[0]['parent_uri']), dbesc($r[0]['parent_mid']),
intval($channel_id) intval($channel_id)
); );
} }

View File

@ -180,21 +180,21 @@ function photo_upload($channel, $observer, $args) {
} }
$basename = basename($filename); $basename = basename($filename);
$uri = item_message_id(); $mid = item_message_id();
// Create item container // Create item container
$item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
$item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
$title = ''; $title = '';
$uri = item_message_id(); $mid = item_message_id();
$arr = array(); $arr = array();
$arr['aid'] = $account_id; $arr['aid'] = $account_id;
$arr['uid'] = $channel_id; $arr['uid'] = $channel_id;
$arr['uri'] = $uri; $arr['mid'] = $mid;
$arr['parent_uri'] = $uri; $arr['parent_mid'] = $mid;
$arr['item_flags'] = $item_flags; $arr['item_flags'] = $item_flags;
$arr['item_restrict'] = $item_restrict; $arr['item_restrict'] = $item_restrict;
$arr['resource_type'] = 'photo'; $arr['resource_type'] = 'photo';
@ -330,14 +330,14 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) {
$item_restrict = (($visible) ? ITEM_HIDDEN : ITEM_VISIBLE); $item_restrict = (($visible) ? ITEM_HIDDEN : ITEM_VISIBLE);
$title = ''; $title = '';
$uri = item_message_id(); $mid = item_message_id();
$arr = array(); $arr = array();
$arr['aid'] = $channel['channel_account_id']; $arr['aid'] = $channel['channel_account_id'];
$arr['uid'] = $channel['channel_id']; $arr['uid'] = $channel['channel_id'];
$arr['uri'] = $uri; $arr['mid'] = $mid;
$arr['parent_uri'] = $uri; $arr['parent_mid'] = $mid;
$arr['item_flags'] = $item_flags; $arr['item_flags'] = $item_flags;
$arr['item_restrict'] = $item_restrict; $arr['item_restrict'] = $item_restrict;
$arr['resource_type'] = 'photo'; $arr['resource_type'] = 'photo';

View File

@ -394,14 +394,14 @@ function item_message_id() {
$dups = false; $dups = false;
$hash = random_string(); $hash = random_string();
$uri = $hash . '@' . get_app()->get_hostname(); $mid = $hash . '@' . get_app()->get_hostname();
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", $r = q("SELECT `id` FROM `item` WHERE `mid` = '%s' LIMIT 1",
dbesc($uri)); dbesc($mid));
if(count($r)) if(count($r))
$dups = true; $dups = true;
} while($dups == true); } while($dups == true);
return $uri; return $mid;
} }
// Generate a guaranteed unique photo ID. // Generate a guaranteed unique photo ID.

View File

@ -926,7 +926,7 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
$channel = $r[0]; $channel = $r[0];
$perm = (($arr['uri'] == $arr['parent_uri']) ? 'send_stream' : 'post_comments'); $perm = (($arr['mid'] == $arr['parent_mid']) ? 'send_stream' : 'post_comments');
if(! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) { if(! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) {
logger("permission denied for delivery {$channel['channel_id']}"); logger("permission denied for delivery {$channel['channel_id']}");
@ -957,13 +957,13 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
$ev['uid'] = $channel['channel_id']; $ev['uid'] = $channel['channel_id'];
$ev['account'] = $channel['channel_account_id']; $ev['account'] = $channel['channel_account_id'];
$ev['edited'] = $arr['edited']; $ev['edited'] = $arr['edited'];
$ev['uri'] = $arr['uri']; $ev['mid'] = $arr['mid'];
$ev['private'] = $arr['item_private']; $ev['private'] = $arr['item_private'];
// is this an edit? // is this an edit?
$r = q("SELECT resource_id FROM item where uri = '%s' and uid = %d and resource_type = 'event' limit 1", $r = q("SELECT resource_id FROM item where mid = '%s' and uid = %d and resource_type = 'event' limit 1",
dbesc($arr['uri']), dbesc($arr['mid']),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
if($r) { if($r) {
@ -979,8 +979,8 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
$r = q("select id, edited from item where uri = '%s' and uid = %d limit 1", $r = q("select id, edited from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['uri']), dbesc($arr['mid']),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
if($r) { if($r) {
@ -1027,10 +1027,10 @@ function delete_imported_item($sender,$item,$uid) {
logger('delete_imported_item invoked',LOGGER_DEBUG); logger('delete_imported_item invoked',LOGGER_DEBUG);
$r = q("select id from item where ( author_xchan = '%s' or owner_xchan = '%s' ) $r = q("select id from item where ( author_xchan = '%s' or owner_xchan = '%s' )
and uri = '%s' and uid = %d limit 1", and mid = '%s' and uid = %d limit 1",
dbesc($sender['hash']), dbesc($sender['hash']),
dbesc($sender['hash']), dbesc($sender['hash']),
dbesc($item['uri']), dbesc($item['mid']),
intval($uid) intval($uid)
); );
@ -1061,8 +1061,8 @@ function process_mail_delivery($sender,$arr,$deliveries) {
continue; continue;
} }
$r = q("select id from mail where uri = '%s' and channel_id = %d limit 1", $r = q("select id from mail where mid = '%s' and channel_id = %d limit 1",
dbesc($arr['uri']), dbesc($arr['mid']),
intval($channel['channel_id']) intval($channel['channel_id'])
); );
if($r) { if($r) {

View File

@ -423,12 +423,12 @@ CREATE TABLE IF NOT EXISTS `issue` (
CREATE TABLE IF NOT EXISTS `item` ( CREATE TABLE IF NOT EXISTS `item` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT, `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uri` char(255) CHARACTER SET ascii NOT NULL DEFAULT '', `mid` char(255) CHARACTER SET ascii NOT NULL DEFAULT '',
`aid` int(10) unsigned NOT NULL DEFAULT '0', `aid` int(10) unsigned NOT NULL DEFAULT '0',
`uid` int(10) unsigned NOT NULL DEFAULT '0', `uid` int(10) unsigned NOT NULL DEFAULT '0',
`wall` tinyint(1) NOT NULL DEFAULT '0', `wall` tinyint(1) NOT NULL DEFAULT '0',
`parent` int(10) unsigned NOT NULL DEFAULT '0', `parent` int(10) unsigned NOT NULL DEFAULT '0',
`parent_uri` char(255) CHARACTER SET ascii NOT NULL DEFAULT '', `parent_mid` char(255) CHARACTER SET ascii NOT NULL DEFAULT '',
`thr_parent` char(255) NOT NULL DEFAULT '', `thr_parent` char(255) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `edited` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
@ -466,7 +466,6 @@ CREATE TABLE IF NOT EXISTS `item` (
`item_flags` int(11) NOT NULL DEFAULT '0', `item_flags` int(11) NOT NULL DEFAULT '0',
`item_private` tinyint(4) NOT NULL DEFAULT '0', `item_private` tinyint(4) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `uri` (`uri`),
KEY `uid` (`uid`), KEY `uid` (`uid`),
KEY `parent` (`parent`), KEY `parent` (`parent`),
KEY `created` (`created`), KEY `created` (`created`),
@ -475,14 +474,12 @@ CREATE TABLE IF NOT EXISTS `item` (
KEY `wall` (`wall`), KEY `wall` (`wall`),
KEY `uid_commented` (`uid`,`commented`), KEY `uid_commented` (`uid`,`commented`),
KEY `uid_created` (`uid`,`created`), KEY `uid_created` (`uid`,`created`),
KEY `parent_uri` (`parent_uri`),
KEY `aid` (`aid`), KEY `aid` (`aid`),
KEY `owner_xchan` (`owner_xchan`), KEY `owner_xchan` (`owner_xchan`),
KEY `author_xchan` (`author_xchan`), KEY `author_xchan` (`author_xchan`),
KEY `resource_type` (`resource_type`), KEY `resource_type` (`resource_type`),
KEY `item_restrict` (`item_restrict`), KEY `item_restrict` (`item_restrict`),
KEY `item_flags` (`item_flags`), KEY `item_flags` (`item_flags`),
KEY `uid_uri` (`uri`,`uid`),
KEY `commented` (`commented`), KEY `commented` (`commented`),
KEY `verb` (`verb`), KEY `verb` (`verb`),
KEY `item_private` (`item_private`), KEY `item_private` (`item_private`),
@ -490,6 +487,9 @@ CREATE TABLE IF NOT EXISTS `item` (
KEY `expires` (`expires`), KEY `expires` (`expires`),
KEY `revision` (`revision`), KEY `revision` (`revision`),
KEY `mimetype` (`mimetype`), KEY `mimetype` (`mimetype`),
KEY `mid` (`mid`),
KEY `parent_mid` (`parent_mid`),
KEY `uid_mid` (`mid`,`uid`),
FULLTEXT KEY `title` (`title`), FULLTEXT KEY `title` (`title`),
FULLTEXT KEY `body` (`body`), FULLTEXT KEY `body` (`body`),
FULLTEXT KEY `allow_cid` (`allow_cid`), FULLTEXT KEY `allow_cid` (`allow_cid`),
@ -520,18 +520,18 @@ CREATE TABLE IF NOT EXISTS `mail` (
`channel_id` int(10) unsigned NOT NULL, `channel_id` int(10) unsigned NOT NULL,
`title` char(255) NOT NULL, `title` char(255) NOT NULL,
`body` mediumtext NOT NULL, `body` mediumtext NOT NULL,
`uri` char(255) NOT NULL, `mid` char(255) NOT NULL,
`parent_uri` char(255) NOT NULL, `parent_mid` char(255) NOT NULL,
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
KEY `uri` (`uri`),
KEY `created` (`created`), KEY `created` (`created`),
KEY `mail_flags` (`mail_flags`), KEY `mail_flags` (`mail_flags`),
KEY `account_id` (`account_id`), KEY `account_id` (`account_id`),
KEY `channel_id` (`channel_id`), KEY `channel_id` (`channel_id`),
KEY `parent_uri` (`parent_uri`),
KEY `from_xchan` (`from_xchan`), KEY `from_xchan` (`from_xchan`),
KEY `to_xchan` (`to_xchan`) KEY `to_xchan` (`to_xchan`),
KEY `mid` (`mid`),
KEY `parent_mid` (`parent_mid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `manage` ( CREATE TABLE IF NOT EXISTS `manage` (

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1037 ); define( 'UPDATE_VERSION' , 1038 );
/** /**
* *
@ -464,5 +464,36 @@ KEY `k` ( `k` )
} }
function update_r1036() { function update_r1036() {
q("ALTER TABLE `profile` ADD `channels` TEXT NOT NULL AFTER `contact` "); $r = q("ALTER TABLE `profile` ADD `channels` TEXT NOT NULL AFTER `contact` ");
if($r)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
} }
function update_r1037() {
$r1 = q("ALTER TABLE `item` CHANGE `uri` `mid` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '',
CHANGE `parent_uri` `parent_mid` CHAR( 255 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL DEFAULT '',
DROP INDEX `uri` ,
ADD INDEX `mid` ( `mid` ),
DROP INDEX `parent_uri` ,
ADD INDEX `parent_mid` ( `parent_mid` ),
DROP INDEX `uid_uri` ,
ADD INDEX `uid_mid` ( `mid` , `uid` ) ");
$r2 = q("ALTER TABLE `mail` CHANGE `uri` `mid` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
CHANGE `parent_uri` `parent_mid` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ,
DROP INDEX `uri` ,
ADD INDEX `mid` ( `mid` ),
DROP INDEX `parent_uri` ,
ADD INDEX `parent_mid` ( `parent_mid` ) ");
if($r1 && $r2)
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}

View File

@ -47,7 +47,7 @@ function community_content(&$a, $update = 0) {
// OR your own posts if you are a logged in member // OR your own posts if you are a logged in member
if(! get_pconfig(local_user(),'system','alt_pager')) { if(! get_pconfig(local_user(),'system','alt_pager')) {
$r = q("SELECT COUNT(distinct(`item`.`uri`)) AS `total` $r = q("SELECT COUNT(distinct(`item`.`mid`)) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
@ -66,7 +66,7 @@ function community_content(&$a, $update = 0) {
} }
$r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT distinct(`item`.`mid`), `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
@ -77,7 +77,7 @@ function community_content(&$a, $update = 0) {
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`mid`
ORDER BY `received` DESC LIMIT %d, %d ", ORDER BY `received` DESC LIMIT %d, %d ",
intval($a->pager['start']), intval($a->pager['start']),
intval($a->pager['itemspage']) intval($a->pager['itemspage'])

View File

@ -20,8 +20,8 @@ function display_content(&$a, $update = 0, $load = false) {
if(argc() > 1 && argv(1) !== 'load') if(argc() > 1 && argv(1) !== 'load')
$item_hash = argv(1); $item_hash = argv(1);
if($_REQUEST['uri']) if($_REQUEST['mid'])
$item_hash = $_REQUEST['uri']; $item_hash = $_REQUEST['mid'];
if(! $item_hash) { if(! $item_hash) {
@ -43,7 +43,7 @@ function display_content(&$a, $update = 0, $load = false) {
$target_item = null; $target_item = null;
$r = q("select uri, parent_uri from item where uri = '%s' limit 1", $r = q("select mid, parent_mid from item where mid = '%s' limit 1",
dbesc($item_hash) dbesc($item_hash)
); );
@ -98,22 +98,22 @@ function display_content(&$a, $update = 0, $load = false) {
$r = q("SELECT * from item $r = q("SELECT * from item
WHERE item_restrict = 0 WHERE item_restrict = 0
and uid = %d and uid = %d
and uri = '%s' and mid = '%s'
limit 1", limit 1",
intval(local_user()), intval(local_user()),
dbesc($target_item['parent_uri']) dbesc($target_item['parent_mid'])
); );
} }
if($r === null) { if($r === null) {
$r = q("SELECT * from item $r = q("SELECT * from item
WHERE item_restrict = 0 WHERE item_restrict = 0
and uri = '%s' and mid = '%s'
AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND ((( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = ''
AND `item`.`deny_gid` = '' AND item_private = 0 ) AND `item`.`deny_gid` = '' AND item_private = 0 )
and uid in ( " . stream_perms_api_uids() . " )) and uid in ( " . stream_perms_api_uids() . " ))
$sql_extra ) $sql_extra )
group by uri limit 1", group by mid limit 1",
dbesc($target_item['parent_uri']) dbesc($target_item['parent_mid'])
); );
} }
@ -150,7 +150,7 @@ function display_content(&$a, $update = 0, $load = false) {
/* /*
elseif((! $update) && (! { elseif((! $update) && (! {
$r = q("SELECT `id`, item_flags FROM `item` WHERE `id` = '%s' OR `uri` = '%s' LIMIT 1", $r = q("SELECT `id`, item_flags FROM `item` WHERE `id` = '%s' OR `mid` = '%s' LIMIT 1",
dbesc($item_hash), dbesc($item_hash),
dbesc($item_hash) dbesc($item_hash)
); );

View File

@ -380,7 +380,7 @@ function events_content(&$a) {
$l_orig = ((x($orig_event)) ? $orig_event['location'] : ''); $l_orig = ((x($orig_event)) ? $orig_event['location'] : '');
$eid = ((x($orig_event)) ? $orig_event['id'] : 0); $eid = ((x($orig_event)) ? $orig_event['id'] : 0);
$event_xchan = ((x($orig_event)) ? $orig_event['event_xchan'] : $channel['channel_hash']); $event_xchan = ((x($orig_event)) ? $orig_event['event_xchan'] : $channel['channel_hash']);
$uri = ((x($orig_event)) ? $orig_event['uri'] : ''); $mid = ((x($orig_event)) ? $orig_event['mid'] : '');
if(! x($orig_event)) if(! x($orig_event))
$sh_checked = ''; $sh_checked = '';
@ -428,7 +428,7 @@ function events_content(&$a) {
'$post' => $a->get_baseurl() . '/events', '$post' => $a->get_baseurl() . '/events',
'$eid' => $eid, '$eid' => $eid,
'$xchan' => $event_xchan, '$xchan' => $event_xchan,
'$uri' => $uri, '$mid' => $mid,
'$title' => t('Event details'), '$title' => t('Event details'),
'$desc' => sprintf( t('Format is %s %s. Starting date and Title are required.'),$dateformat,$timeformat), '$desc' => sprintf( t('Format is %s %s. Starting date and Title are required.'),$dateformat,$timeformat),

View File

@ -80,7 +80,7 @@ function item_post(&$a) {
*/ */
$parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0);
$parent_uri = ((x($_REQUEST,'parent_uri')) ? trim($_REQUEST['parent_uri']) : ''); $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : '');
$parent_item = null; $parent_item = null;
$parent_contact = null; $parent_contact = null;
@ -88,7 +88,7 @@ function item_post(&$a) {
$parid = 0; $parid = 0;
$r = false; $r = false;
if($parent || $parent_uri) { if($parent || $parent_mid) {
if(! x($_REQUEST,'type')) if(! x($_REQUEST,'type'))
$_REQUEST['type'] = 'net-comment'; $_REQUEST['type'] = 'net-comment';
@ -98,17 +98,17 @@ function item_post(&$a) {
intval($parent) intval($parent)
); );
} }
elseif($parent_uri && local_user()) { elseif($parent_mid && local_user()) {
// This is coming from an API source, and we are logged in // This is coming from an API source, and we are logged in
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($parent_uri), dbesc($parent_mid),
intval(local_user()) intval(local_user())
); );
} }
// if this isn't the real parent of the conversation, find it // if this isn't the real parent of the conversation, find it
if($r !== false && count($r)) { if($r !== false && count($r)) {
$parid = $r[0]['parent']; $parid = $r[0]['parent'];
$parent_uri = $r[0]['uri']; $parent_mid = $r[0]['mid'];
if($r[0]['id'] != $r[0]['parent']) { if($r[0]['id'] != $r[0]['parent']) {
$r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1", $r = q("SELECT * FROM `item` WHERE `id` = `parent` AND `parent` = %d LIMIT 1",
intval($parid) intval($parid)
@ -127,7 +127,7 @@ function item_post(&$a) {
// multi-level threading - preserve the info but re-parent to our single level threading // multi-level threading - preserve the info but re-parent to our single level threading
//if(($parid) && ($parid != $parent)) //if(($parid) && ($parid != $parent))
$thr_parent = $parent_uri; $thr_parent = $parent_mid;
if($parent_item['contact-id'] && $uid) { if($parent_item['contact-id'] && $uid) {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@ -474,20 +474,20 @@ function item_post(&$a) {
$notify_type = (($parent) ? 'comment-new' : 'wall-new' ); $notify_type = (($parent) ? 'comment-new' : 'wall-new' );
$uri = item_message_id(); $mid = item_message_id();
$parent_uri = $uri; $parent_mid = $mid;
if($parent_item) if($parent_item)
$parent_uri = $parent_item['uri']; $parent_mid = $parent_item['mid'];
// Fallback so that we alway have a thr_parent // Fallback so that we alway have a thr_parent
if(!$thr_parent) if(!$thr_parent)
$thr_parent = $uri; $thr_parent = $mid;
$datarray = array(); $datarray = array();
if(! $parent) { if(! $parent) {
$datarray['parent_uri'] = $uri; $datarray['parent_mid'] = $mid;
$item_flags = $item_flags | ITEM_THREAD_TOP; $item_flags = $item_flags | ITEM_THREAD_TOP;
} }
@ -502,8 +502,8 @@ function item_post(&$a) {
$datarray['commented'] = datetime_convert(); $datarray['commented'] = datetime_convert();
$datarray['received'] = datetime_convert(); $datarray['received'] = datetime_convert();
$datarray['changed'] = datetime_convert(); $datarray['changed'] = datetime_convert();
$datarray['uri'] = $uri; $datarray['mid'] = $mid;
$datarray['parent_uri'] = $parent_uri; $datarray['parent_mid'] = $parent_mid;
$datarray['mimetype'] = $content_type; $datarray['mimetype'] = $content_type;
$datarray['title'] = $title; $datarray['title'] = $title;
$datarray['body'] = $body; $datarray['body'] = $body;
@ -632,11 +632,11 @@ function item_post(&$a) {
'from_xchan' => $datarray['author_xchan'], 'from_xchan' => $datarray['author_xchan'],
'to_xchan' => $datarray['owner_xchan'], 'to_xchan' => $datarray['owner_xchan'],
'item' => $datarray, 'item' => $datarray,
'link' => $a->get_baseurl() . '/display/' . $datarray['uri'], 'link' => $a->get_baseurl() . '/display/' . $datarray['mid'],
'verb' => ACTIVITY_POST, 'verb' => ACTIVITY_POST,
'otype' => 'item', 'otype' => 'item',
'parent' => $parent, 'parent' => $parent,
'parent_uri' => $parent_item['uri'] 'parent_mid' => $parent_item['mid']
)); ));
} }
@ -651,7 +651,7 @@ function item_post(&$a) {
'from_xchan' => $datarray['author_xchan'], 'from_xchan' => $datarray['author_xchan'],
'to_xchan' => $datarray['owner_xchan'], 'to_xchan' => $datarray['owner_xchan'],
'item' => $datarray, 'item' => $datarray,
'link' => $a->get_baseurl() . '/display/' . $datarray['uri'], 'link' => $a->get_baseurl() . '/display/' . $datarray['mid'],
'verb' => ACTIVITY_POST, 'verb' => ACTIVITY_POST,
'otype' => 'item' 'otype' => 'item'
)); ));
@ -663,10 +663,10 @@ function item_post(&$a) {
if(! $parent) if(! $parent)
$parent = $post_id; $parent = $post_id;
$r = q("UPDATE `item` SET `parent` = %d, `parent_uri` = '%s', `changed` = '%s' $r = q("UPDATE `item` SET `parent` = %d, `parent_mid` = '%s', `changed` = '%s'
WHERE `id` = %d LIMIT 1", WHERE `id` = %d LIMIT 1",
intval($parent), intval($parent),
dbesc(($parent == $post_id) ? $uri : $parent_item['uri']), dbesc(($parent == $post_id) ? $mid : $parent_item['mid']),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($post_id) intval($post_id)
); );
@ -704,14 +704,14 @@ function item_post(&$a) {
// store page info as an alternate message_id so we can access it via // store page info as an alternate message_id so we can access it via
// https://sitename/page/$channelname/$pagetitle // https://sitename/page/$channelname/$pagetitle
// if no pagetitle was given or it couldn't be transliterated into a url, use the first // if no pagetitle was given or it couldn't be transliterated into a url, use the first
// sixteen bytes of the uri - which makes the link portable and not quite as daunting // sixteen bytes of the mid - which makes the link portable and not quite as daunting
// as the entire uri. If it were the post_id the link would be less portable. // as the entire mid. If it were the post_id the link would be less portable.
// We should have the ability to edit this and arrange pages into menus via the pages module // We should have the ability to edit this and arrange pages into menus via the pages module
q("insert into item_id ( iid, uid, sid, service ) values ( %d, %d, '%s','%s' )", q("insert into item_id ( iid, uid, sid, service ) values ( %d, %d, '%s','%s' )",
intval($post_id), intval($post_id),
intval($channel['channel_id']), intval($channel['channel_id']),
dbesc(($pagetitle) ? $pagetitle : substr($uri,0,16)), dbesc(($pagetitle) ? $pagetitle : substr($mid,0,16)),
dbesc('WEBPAGE') dbesc('WEBPAGE')
); );
} }

View File

@ -78,7 +78,7 @@ function like_content(&$a) {
dbesc($activity), dbesc($activity),
dbesc($observer['xchan_hash']), dbesc($observer['xchan_hash']),
intval($item_id), intval($item_id),
dbesc($item['uri']) dbesc($item['mid'])
); );
if($r) { if($r) {
$like_item = $r[0]; $like_item = $r[0];
@ -97,19 +97,19 @@ function like_content(&$a) {
$uri = item_message_id(); $mid = item_message_id();
$post_type = (($item['resource_type'] === 'photo') ? $t('photo') : t('status')); $post_type = (($item['resource_type'] === 'photo') ? $t('photo') : t('status'));
$links = array(array('rel' => 'alternate','type' => 'text/html', $links = array(array('rel' => 'alternate','type' => 'text/html',
'href' => z_root() . '/display/' . $item['uri'])); 'href' => z_root() . '/display/' . $item['mid']));
$objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); $objtype = (($item['resource_type'] === 'photo') ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
$body = $item['body']; $body = $item['body'];
$obj = json_encode(array( $obj = json_encode(array(
'type' => $objtype, 'type' => $objtype,
'id' => $item['uri'], 'id' => $item['mid'],
'link' => $links, 'link' => $links,
'title' => $item['title'], 'title' => $item['title'],
'content' => $item['body'], 'content' => $item['body'],
@ -139,19 +139,19 @@ function like_content(&$a) {
$arr = array(); $arr = array();
$arr['uri'] = $uri; $arr['mid'] = $mid;
$arr['uid'] = $owner_uid; $arr['uid'] = $owner_uid;
$arr['item_flags'] = $item_flags; $arr['item_flags'] = $item_flags;
$arr['parent'] = $item['id']; $arr['parent'] = $item['id'];
$arr['parent_uri'] = $item['uri']; $arr['parent_mid'] = $item['mid'];
$arr['thr_parent'] = $item['uri']; $arr['thr_parent'] = $item['mid'];
$arr['owner_xchan'] = $thread_owner['xchan_hash']; $arr['owner_xchan'] = $thread_owner['xchan_hash'];
$arr['author_xchan'] = $observer['xchan_hash']; $arr['author_xchan'] = $observer['xchan_hash'];
$ulink = '[url=' . $thread_owner['xchan_url'] . ']' . $thread_owner['xchan_name'] . '[/url]'; $ulink = '[url=' . $thread_owner['xchan_url'] . ']' . $thread_owner['xchan_name'] . '[/url]';
$alink = '[url=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/url]'; $alink = '[url=' . $observer['xchan_url'] . ']' . $observer['xchan_name'] . '[/url]';
$plink = '[url=' . $a->get_baseurl() . '/display/' . $item['uri'] . ']' . $post_type . '[/url]'; $plink = '[url=' . $a->get_baseurl() . '/display/' . $item['mid'] . ']' . $post_type . '[/url]';
$arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink ); $arr['body'] = sprintf( $bodyverb, $alink, $ulink, $plink );

View File

@ -392,7 +392,7 @@ function message_content(&$a) {
// FIXME - move this HTML to template // FIXME - move this HTML to template
$select = $message[$recp]['xchan_name'] . '<input type="hidden" name="messageto" value="' . $message[$recp]['xchan_hash'] . '" />'; $select = $message[$recp]['xchan_name'] . '<input type="hidden" name="messageto" value="' . $message[$recp]['xchan_hash'] . '" />';
$parent = '<input type="hidden" name="replyto" value="' . $message['parent_uri'] . '" />'; $parent = '<input type="hidden" name="replyto" value="' . $message['parent_mid'] . '" />';
$tpl = get_markup_template('mail_display.tpl'); $tpl = get_markup_template('mail_display.tpl');
$o = replace_macros($tpl, array( $o = replace_macros($tpl, array(

View File

@ -30,14 +30,14 @@ function mood_init(&$a) {
if($parent) { if($parent) {
$r = q("select uri, owner_xchan, private, allow_cid, allow_gid, deny_cid, deny_gid $r = q("select mid, owner_xchan, private, allow_cid, allow_gid, deny_cid, deny_gid
from item where id = %d and parent = %d and uid = %d limit 1", from item where id = %d and parent = %d and uid = %d limit 1",
intval($parent), intval($parent),
intval($parent), intval($parent),
intval($uid) intval($uid)
); );
if(count($r)) { if(count($r)) {
$parent_uri = $r[0]['uri']; $parent_mid = $r[0]['mid'];
$private = $r[0]['private']; $private = $r[0]['private'];
$allow_cid = $r[0]['allow_cid']; $allow_cid = $r[0]['allow_cid'];
$allow_gid = $r[0]['allow_gid']; $allow_gid = $r[0]['allow_gid'];
@ -58,11 +58,11 @@ function mood_init(&$a) {
$poster = $a->get_observer(); $poster = $a->get_observer();
$uri = item_message_id(); $mid = item_message_id();
$action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/url]' , $verbs[$verb]); $action = sprintf( t('%1$s is currently %2$s'), '[url=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/url]' , $verbs[$verb]);
$item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN; $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN;
if(! $parent_uri) if(! $parent_mid)
$item_flags |= ITEM_THREAD_TOP; $item_flags |= ITEM_THREAD_TOP;
@ -70,11 +70,11 @@ function mood_init(&$a) {
$arr['aid'] = get_account_id(); $arr['aid'] = get_account_id();
$arr['uid'] = $uid; $arr['uid'] = $uid;
$arr['uri'] = $uri; $arr['mid'] = $mid;
$arr['parent_uri'] = (($parent_uri) ? $parent_uri : $uri); $arr['parent_mid'] = (($parent_mid) ? $parent_mid : $mid);
$arr['item_flags'] = $item_flags; $arr['item_flags'] = $item_flags;
$arr['author_xchan'] = $poster['xchan_hash']; $arr['author_xchan'] = $poster['xchan_hash'];
$arr['owner_xchan'] = (($parent_uri) ? $r[0]['owner_xchan'] : $poster['xchan_hash']); $arr['owner_xchan'] = (($parent_mid) ? $r[0]['owner_xchan'] : $poster['xchan_hash']);
$arr['title'] = ''; $arr['title'] = '';
$arr['allow_cid'] = $allow_cid; $arr['allow_cid'] = $allow_cid;
$arr['allow_gid'] = $allow_gid; $arr['allow_gid'] = $allow_gid;

View File

@ -187,10 +187,10 @@ function photos_post(&$a) {
intval($page_owner_uid) intval($page_owner_uid)
); );
if(count($i)) { if(count($i)) {
q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent_uri` = '%s' AND `uid` = %d", q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent_mid` = '%s' AND `uid` = %d",
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc($i[0]['uri']), dbesc($i[0]['mid']),
intval($page_owner_uid) intval($page_owner_uid)
); );
@ -459,13 +459,13 @@ function photos_post(&$a) {
if(count($taginfo)) { if(count($taginfo)) {
foreach($taginfo as $tagged) { foreach($taginfo as $tagged) {
$uri = item_message_id(); $mid = item_message_id();
$arr = array(); $arr = array();
$arr['uid'] = $page_owner_uid; $arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri; $arr['mid'] = $mid;
$arr['parent_uri'] = $uri; $arr['parent_mid'] = $mid;
$arr['type'] = 'activity'; $arr['type'] = 'activity';
$arr['wall'] = 1; $arr['wall'] = 1;
$arr['contact-id'] = $owner_record['id']; $arr['contact-id'] = $owner_record['id'];
@ -1000,12 +1000,12 @@ function photos_content(&$a) {
$link_item = $linked_items[0]; $link_item = $linked_items[0];
$r = q("SELECT COUNT(*) AS `total` $r = q("SELECT COUNT(*) AS `total`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `parent_uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `parent_mid` = '%s' AND `mid` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`uid` = %d AND `item`.`uid` = %d
$sql_extra ", $sql_extra ",
dbesc($link_item['uri']), dbesc($link_item['mid']),
dbesc($link_item['uri']), dbesc($link_item['mid']),
intval($link_item['uid']) intval($link_item['uid'])
); );
@ -1019,13 +1019,13 @@ function photos_content(&$a) {
`contact`.`rel`, `contact`.`thumb`, `contact`.`self`, `contact`.`rel`, `contact`.`thumb`, `contact`.`self`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `parent_uri` = '%s' AND `uri` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0 WHERE `parent_mid` = '%s' AND `mid` != '%s' AND `item`.`deleted` = 0 and `item`.`moderated` = 0
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
AND `item`.`uid` = %d AND `item`.`uid` = %d
$sql_extra $sql_extra
ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ",
dbesc($link_item['uri']), dbesc($link_item['mid']),
dbesc($link_item['uri']), dbesc($link_item['mid']),
intval($link_item['uid']), intval($link_item['uid']),
intval($a->pager['start']), intval($a->pager['start']),
intval($a->pager['itemspage']) intval($a->pager['itemspage'])

View File

@ -46,14 +46,14 @@ function poke_init(&$a) {
$target = $r[0]; $target = $r[0];
if($parent) { if($parent) {
$r = q("select uri, private, allow_cid, allow_gid, deny_cid, deny_gid $r = q("select mid, private, allow_cid, allow_gid, deny_cid, deny_gid
from item where id = %d and parent = %d and uid = %d limit 1", from item where id = %d and parent = %d and uid = %d limit 1",
intval($parent), intval($parent),
intval($parent), intval($parent),
intval($uid) intval($uid)
); );
if(count($r)) { if(count($r)) {
$parent_uri = $r[0]['uri']; $parent_mid = $r[0]['mid'];
$private = $r[0]['private']; $private = $r[0]['private'];
$allow_cid = $r[0]['allow_cid']; $allow_cid = $r[0]['allow_cid'];
$allow_gid = $r[0]['allow_gid']; $allow_gid = $r[0]['allow_gid'];
@ -76,13 +76,13 @@ function poke_init(&$a) {
$poster = $a->contact; $poster = $a->contact;
$uri = item_message_id(); $mid = item_message_id();
$arr = array(); $arr = array();
$arr['uid'] = $uid; $arr['uid'] = $uid;
$arr['uri'] = $uri; $arr['mid'] = $mid;
$arr['parent_uri'] = (($parent_uri) ? $parent_uri : $uri); $arr['parent_mid'] = (($parent_mid) ? $parent_mid : $mid);
$arr['type'] = 'activity'; $arr['type'] = 'activity';
$arr['wall'] = 1; $arr['wall'] = 1;
$arr['contact-id'] = $poster['id']; $arr['contact-id'] = $poster['id'];

View File

@ -190,12 +190,12 @@ function search_content(&$a) {
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
if($load) { if($load) {
$r = q("SELECT distinct(uri), item.* from item $r = q("SELECT distinct(mid), item.* from item
WHERE item_restrict = 0 WHERE item_restrict = 0
AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 ) AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND item_private = 0 )
OR ( `item`.`uid` = %d )) OR ( `item`.`uid` = %d ))
$sql_extra $sql_extra
group by uri ORDER BY created DESC $pager_sql ", group by mid ORDER BY created DESC $pager_sql ",
intval(local_user()), intval(local_user()),
intval(ABOOK_FLAG_BLOCKED) intval(ABOOK_FLAG_BLOCKED)
@ -228,7 +228,7 @@ function search_content(&$a) {
$r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, $r = q("SELECT distinct(`item`.`mid`), `item`.*, `item`.`id` AS `item_id`,
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`,
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
@ -240,7 +240,7 @@ function search_content(&$a) {
OR `item`.`uid` = %d ) OR `item`.`uid` = %d )
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
$sql_extra $sql_extra
group by `item`.`uri` group by `item`.`mid`
ORDER BY `received` DESC LIMIT %d , %d ", ORDER BY `received` DESC LIMIT %d , %d ",
intval(local_user()), intval(local_user()),
intval($a->pager['start']), intval($a->pager['start']),

View File

@ -15,7 +15,7 @@ function subthread_content(&$a) {
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0); $item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
$r = q("SELECT * FROM `item` WHERE `parent` = '%s' OR `parent-uri` = '%s' and parent = id LIMIT 1", $r = q("SELECT * FROM `item` WHERE `parent` = '%s' OR `parent-mid` = '%s' and parent = id LIMIT 1",
dbesc($item_id), dbesc($item_id),
dbesc($item_id) dbesc($item_id)
); );
@ -84,7 +84,7 @@ function subthread_content(&$a) {
return; return;
} }
$uri = item_message_id(); $mid = item_message_id();
$post_type = (($item['resource_id']) ? t('photo') : t('status')); $post_type = (($item['resource_id']) ? t('photo') : t('status'));
$objtype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); $objtype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
@ -96,7 +96,7 @@ function subthread_content(&$a) {
<object> <object>
<type>$objtype</type> <type>$objtype</type>
<local>1</local> <local>1</local>
<id>{$item['uri']}</id> <id>{$item['mid']}</id>
<link>$link</link> <link>$link</link>
<title></title> <title></title>
<content>$body</content> <content>$body</content>
@ -109,7 +109,7 @@ EOT;
$arr = array(); $arr = array();
$arr['uri'] = $uri; $arr['mid'] = $mid;
$arr['uid'] = $owner_uid; $arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id']; $arr['contact-id'] = $contact['id'];
$arr['type'] = 'activity'; $arr['type'] = 'activity';
@ -117,8 +117,8 @@ EOT;
$arr['origin'] = 1; $arr['origin'] = 1;
$arr['gravity'] = GRAVITY_LIKE; $arr['gravity'] = GRAVITY_LIKE;
$arr['parent'] = $item['id']; $arr['parent'] = $item['id'];
$arr['parent-uri'] = $item['uri']; $arr['parent-mid'] = $item['mid'];
$arr['thr_parent'] = $item['uri']; $arr['thr_parent'] = $item['mid'];
$arr['owner-name'] = $remote_owner['name']; $arr['owner-name'] = $remote_owner['name'];
$arr['owner-link'] = $remote_owner['url']; $arr['owner-link'] = $remote_owner['url'];
$arr['owner-avatar'] = $remote_owner['thumb']; $arr['owner-avatar'] = $remote_owner['thumb'];

View File

@ -57,7 +57,7 @@ function tagger_content(&$a) {
return; return;
} }
$uri = item_message_id(); $mid = item_message_id();
$xterm = xmlify($term); $xterm = xmlify($term);
$post_type = (($item['resource_id']) ? t('photo') : t('status')); $post_type = (($item['resource_id']) ? t('photo') : t('status'));
$targettype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE ); $targettype = (($item['resource_id']) ? ACTIVITY_OBJ_PHOTO : ACTIVITY_OBJ_NOTE );
@ -71,7 +71,7 @@ function tagger_content(&$a) {
<target> <target>
<type>$targettype</type> <type>$targettype</type>
<local>1</local> <local>1</local>
<id>{$item['uri']}</id> <id>{$item['mid']}</id>
<link>$link</link> <link>$link</link>
<title></title> <title></title>
<content>$body</content> <content>$body</content>
@ -101,14 +101,14 @@ EOT;
$arr = array(); $arr = array();
$arr['uri'] = $uri; $arr['mid'] = $mid;
$arr['uid'] = $owner_uid; $arr['uid'] = $owner_uid;
$arr['contact-id'] = $contact['id']; $arr['contact-id'] = $contact['id'];
$arr['type'] = 'activity'; $arr['type'] = 'activity';
$arr['wall'] = $item['wall']; $arr['wall'] = $item['wall'];
$arr['gravity'] = GRAVITY_COMMENT; $arr['gravity'] = GRAVITY_COMMENT;
$arr['parent'] = $item['id']; $arr['parent'] = $item['id'];
$arr['parent_uri'] = $item['uri']; $arr['parent_mid'] = $item['mid'];
$arr['owner-name'] = $item['author-name']; $arr['owner-name'] = $item['author-name'];
$arr['owner-link'] = $item['author-link']; $arr['owner-link'] = $item['author-link'];
$arr['owner-avatar'] = $item['author-avatar']; $arr['owner-avatar'] = $item['author-avatar'];
@ -159,8 +159,8 @@ EOT;
// if the original post is on this site, update it. // if the original post is on this site, update it.
$r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `uri` = '%s' LIMIT 1", $r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `mid` = '%s' LIMIT 1",
dbesc($item['uri']) dbesc($item['mid'])
); );
if(count($r)) { if(count($r)) {
$x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1", $x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1",

View File

@ -8,7 +8,7 @@ $desc
<input type="hidden" name="event_id" value="$eid" /> <input type="hidden" name="event_id" value="$eid" />
<input type="hidden" name="cid" value="$cid" /> <input type="hidden" name="cid" value="$cid" />
<input type="hidden" name="uri" value="$uri" /> <input type="hidden" name="mid" value="$mid" />
<div id="event-start-text">$s_text</div> <div id="event-start-text">$s_text</div>
$s_dsel $s_tsel $s_dsel $s_tsel

View File

@ -13,7 +13,7 @@
<input type="hidden" name="event_id" value="{{$eid}}" /> <input type="hidden" name="event_id" value="{{$eid}}" />
<input type="hidden" name="cid" value="{{$cid}}" /> <input type="hidden" name="cid" value="{{$cid}}" />
<input type="hidden" name="uri" value="{{$uri}}" /> <input type="hidden" name="mid" value="{{$mid}}" />
<div id="event-start-text">{{$s_text}}</div> <div id="event-start-text">{{$s_text}}</div>
{{$s_dsel}} {{$s_tsel}} {{$s_dsel}} {{$s_tsel}}