Merge pull request #2624 from annando/1606-contact-id
Item: New fields for author id and owner id - avatar improvement with relocation
This commit is contained in:
commit
cd92a0dc34
18 changed files with 224 additions and 171 deletions
|
@ -120,19 +120,17 @@ function community_getitems($start, $itemspage) {
|
|||
if (get_config('system','community_page_style') == CP_GLOBAL_COMMUNITY)
|
||||
return(community_getpublicitems($start, $itemspage));
|
||||
|
||||
$r = q("SELECT %s, %s, `user`.`nickname`
|
||||
$r = q("SELECT %s
|
||||
FROM `thread` FORCE INDEX (`wall_private_received`)
|
||||
INNER JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
|
||||
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = ''
|
||||
INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
|
||||
AND %s AND `contact`.`self`
|
||||
%s AND `contact`.`self`
|
||||
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
|
||||
AND NOT `thread`.`private` AND `thread`.`wall`
|
||||
ORDER BY `thread`.`received` DESC LIMIT %d, %d",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(),
|
||||
item_fieldlists(), item_joins(),
|
||||
intval($start), intval($itemspage)
|
||||
);
|
||||
|
||||
|
@ -142,14 +140,13 @@ function community_getitems($start, $itemspage) {
|
|||
|
||||
function community_getpublicitems($start, $itemspage) {
|
||||
|
||||
$r = q("SELECT %s, `author-name` AS `name`, `owner-avatar` AS `photo`,
|
||||
`owner-link` AS `url`, `owner-avatar` AS `thumb`
|
||||
$r = q("SELECT %s
|
||||
FROM `thread`
|
||||
INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
INNER JOIN `item` ON `item`.`id` = `thread`.`iid` %s
|
||||
WHERE `thread`.`uid` = 0
|
||||
ORDER BY `thread`.`created` DESC LIMIT %d, %d",
|
||||
item_fieldlist(), intval($start),
|
||||
intval($itemspage)
|
||||
item_fieldlists(), item_joins(),
|
||||
intval($start), intval($itemspage)
|
||||
);
|
||||
|
||||
return($r);
|
||||
|
|
|
@ -362,18 +362,15 @@ function display_content(&$a, $update = 0) {
|
|||
return '';
|
||||
}
|
||||
|
||||
$r = q("SELECT %s, %s FROM `item`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
WHERE %s AND `item`.`uid` = %d
|
||||
$r = q(item_query()." AND `item`.`uid` = %d
|
||||
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `id` = %d)
|
||||
$sql_extra
|
||||
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(), item_condition(),
|
||||
intval($a->profile['uid']),
|
||||
intval($item_id)
|
||||
);
|
||||
|
||||
|
||||
if(!$r && local_user()) {
|
||||
// Check if this is another person's link to a post that we have
|
||||
$r = q("SELECT `item`.uri FROM `item`
|
||||
|
@ -385,13 +382,9 @@ function display_content(&$a, $update = 0) {
|
|||
if($r) {
|
||||
$item_uri = $r[0]['uri'];
|
||||
|
||||
$r = q("SELECT %s, %s FROM `item`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
WHERE %s AND `item`.`uid` = %d
|
||||
$r = q(item_query()." AND `item`.`uid` = %d
|
||||
AND `item`.`parent` = (SELECT `parent` FROM `item` WHERE `uri` = '%s' AND uid = %d)
|
||||
ORDER BY `parent` DESC, `gravity` ASC, `id` ASC ",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(), item_condition(),
|
||||
intval(local_user()),
|
||||
dbesc($item_uri),
|
||||
intval(local_user())
|
||||
|
@ -399,7 +392,6 @@ function display_content(&$a, $update = 0) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
if($r) {
|
||||
|
||||
if((local_user()) && (local_user() == $a->profile['uid'])) {
|
||||
|
|
28
mod/item.php
28
mod/item.php
|
@ -25,6 +25,7 @@ require_once('include/text.php');
|
|||
require_once('include/items.php');
|
||||
require_once('include/Scrape.php');
|
||||
require_once('include/diaspora.php');
|
||||
require_once('include/Contact.php');
|
||||
|
||||
function item_post(&$a) {
|
||||
|
||||
|
@ -676,9 +677,11 @@ function item_post(&$a) {
|
|||
$datarray['owner-name'] = $contact_record['name'];
|
||||
$datarray['owner-link'] = $contact_record['url'];
|
||||
$datarray['owner-avatar'] = $contact_record['thumb'];
|
||||
$datarray["owner-id"] = get_contact($datarray["owner-link"], 0);
|
||||
$datarray['author-name'] = $author['name'];
|
||||
$datarray['author-link'] = $author['url'];
|
||||
$datarray['author-avatar'] = $author['thumb'];
|
||||
$datarray["author-id"] = get_contact($datarray["author-link"], 0);
|
||||
$datarray['created'] = datetime_convert();
|
||||
$datarray['edited'] = datetime_convert();
|
||||
$datarray['commented'] = datetime_convert();
|
||||
|
@ -711,6 +714,7 @@ function item_post(&$a) {
|
|||
$datarray['moderated'] = $allow_moderated;
|
||||
$datarray['gcontact-id'] = get_gcontact_id(array("url" => $datarray['author-link'], "network" => $datarray['network'],
|
||||
"photo" => $datarray['author-avatar'], "name" => $datarray['author-name']));
|
||||
|
||||
/**
|
||||
* These fields are for the convenience of plugins...
|
||||
* 'self' if true indicates the owner is posting on their own wall
|
||||
|
@ -790,10 +794,24 @@ function item_post(&$a) {
|
|||
$post_id = 0;
|
||||
|
||||
|
||||
$r = q("INSERT INTO `item` (`guid`, `extid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `author-name`, `author-link`, `author-avatar`,
|
||||
`created`, `edited`, `commented`, `received`, `changed`, `uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`, `tag`, `inform`, `verb`, `object-type`, `postopts`,
|
||||
`allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`, `pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file`, `rendered-html`, `rendered-hash`)
|
||||
VALUES( '%s', '%s', %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, %d, '%s', '%s', '%s')",
|
||||
$r = q("INSERT INTO `item` (`guid`, `extid`, `uid`,`type`,`wall`,`gravity`, `network`, `contact-id`,
|
||||
`owner-name`,`owner-link`,`owner-avatar`, `owner-id`,
|
||||
`author-name`, `author-link`, `author-avatar`, `author-id`,
|
||||
`created`, `edited`, `commented`, `received`, `changed`,
|
||||
`uri`, `thr-parent`, `title`, `body`, `app`, `location`, `coord`,
|
||||
`tag`, `inform`, `verb`, `object-type`, `postopts`,
|
||||
`allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`, `private`,
|
||||
`pubmail`, `attach`, `bookmark`,`origin`, `moderated`, `file`,
|
||||
`rendered-html`, `rendered-hash`)
|
||||
VALUES('%s', '%s', %d, '%s', %d, %d, '%s', %d,
|
||||
'%s', '%s', '%s', %d,
|
||||
'%s', '%s', '%s', %d,
|
||||
'%s', '%s', '%s', '%s', '%s',
|
||||
'%s', '%s', '%s', '%s', '%s', '%s', '%s',
|
||||
'%s', '%s', '%s', '%s', '%s',
|
||||
'%s', '%s', '%s', '%s', %d,
|
||||
%d, '%s', %d, %d, %d, '%s',
|
||||
'%s', '%s')",
|
||||
dbesc($datarray['guid']),
|
||||
dbesc($datarray['extid']),
|
||||
intval($datarray['uid']),
|
||||
|
@ -805,9 +823,11 @@ function item_post(&$a) {
|
|||
dbesc($datarray['owner-name']),
|
||||
dbesc($datarray['owner-link']),
|
||||
dbesc($datarray['owner-avatar']),
|
||||
intval($datarray['owner-id']),
|
||||
dbesc($datarray['author-name']),
|
||||
dbesc($datarray['author-link']),
|
||||
dbesc($datarray['author-avatar']),
|
||||
intval($datarray['author-id']),
|
||||
dbesc($datarray['created']),
|
||||
dbesc($datarray['edited']),
|
||||
dbesc($datarray['commented']),
|
||||
|
|
|
@ -682,8 +682,8 @@ function network_content(&$a, $update = 0) {
|
|||
if(get_config('system', 'old_pager')) {
|
||||
$r = q("SELECT COUNT(*) AS `total`
|
||||
FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = $sql_table.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
WHERE $sql_table.`uid` = %d AND $sql_table.`visible` = 1 AND $sql_table.`deleted` = 0
|
||||
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
|
||||
WHERE $sql_table.`uid` = %d AND $sql_table.`visible` AND NOT $sql_table.`deleted`
|
||||
$sql_extra2 $sql_extra3
|
||||
$sql_extra $sql_nets ",
|
||||
intval($_SESSION['uid'])
|
||||
|
@ -714,20 +714,18 @@ function network_content(&$a, $update = 0) {
|
|||
}
|
||||
|
||||
if($nouveau) {
|
||||
$simple_update = (($update) ? " AND `item`.`unseen` = 1 " : '');
|
||||
$simple_update = (($update) ? " AND `item`.`unseen` " : '');
|
||||
|
||||
if ($sql_order == "")
|
||||
$sql_order = "`item`.`received`";
|
||||
|
||||
// "New Item View" - show all items unthreaded in reverse created date order
|
||||
$items = q("SELECT %s, %s FROM $sql_table $sql_post_table
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
$items = q("SELECT %s FROM $sql_table $sql_post_table %s
|
||||
WHERE %s AND `item`.`uid` = %d
|
||||
$simple_update
|
||||
$sql_extra $sql_nets
|
||||
ORDER BY $sql_order DESC $pager_sql ",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(), item_condition(),
|
||||
item_fieldlists(), item_joins(), item_condition(),
|
||||
intval($_SESSION['uid'])
|
||||
);
|
||||
|
||||
|
@ -755,28 +753,26 @@ function network_content(&$a, $update = 0) {
|
|||
|
||||
// Fetch a page full of parent items for this page
|
||||
if($update) {
|
||||
if (!get_config("system", "like_no_comment"))
|
||||
$sql_extra4 = "(`item`.`deleted` = 0
|
||||
OR `item`.`verb` = '".ACTIVITY_LIKE."' OR `item`.`verb` = '".ACTIVITY_DISLIKE."'
|
||||
OR `item`.`verb` = '".ACTIVITY_ATTEND."' OR `item`.`verb` = '".ACTIVITY_ATTENDNO."'
|
||||
OR `item`.`verb` = '".ACTIVITY_ATTENDMAYBE."')";
|
||||
if (get_config("system", "like_no_comment"))
|
||||
$sql_extra4 = " AND `item`.`verb` = '".ACTIVITY_POST."'";
|
||||
else
|
||||
$sql_extra4 = "`item`.`deleted` = 0 AND `item`.`verb` = '".ACTIVITY_POST."'";
|
||||
$sql_extra4 = "";
|
||||
|
||||
$r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
|
||||
FROM $sql_table $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND $sql_extra4
|
||||
AND `item`.`moderated` = 0 AND `item`.`unseen` = 1
|
||||
$sql_extra3 $sql_extra $sql_nets ORDER BY `item_id` DESC LIMIT 100",
|
||||
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted` $sql_extra4
|
||||
AND NOT `item`.`moderated` AND `item`.`unseen`
|
||||
$sql_extra3 $sql_extra $sql_nets
|
||||
ORDER BY `item_id` DESC LIMIT 100",
|
||||
intval(local_user())
|
||||
);
|
||||
} else {
|
||||
$r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`
|
||||
FROM $sql_table $sql_post_table STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0
|
||||
AND `thread`.`moderated` = 0
|
||||
AND NOT `contact`.`blocked` AND NOT `contact`.`pending`
|
||||
WHERE `thread`.`uid` = %d AND `thread`.`visible` AND NOT `thread`.`deleted`
|
||||
AND NOT `thread`.`moderated`
|
||||
$sql_extra2 $sql_extra3 $sql_extra $sql_nets
|
||||
ORDER BY $sql_order DESC $pager_sql ",
|
||||
intval(local_user())
|
||||
|
@ -806,14 +802,9 @@ function network_content(&$a, $update = 0) {
|
|||
$items = array();
|
||||
|
||||
foreach ($parents_arr AS $parents) {
|
||||
// $sql_extra ORDER BY `item`.`commented` DESC LIMIT %d",
|
||||
$thread_items = q("SELECT %s, %s FROM `item`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
WHERE %s AND `item`.`uid` = %d
|
||||
$thread_items = q(item_query()." AND `item`.`uid` = %d
|
||||
AND `item`.`parent` = %d
|
||||
ORDER BY `item`.`commented` DESC LIMIT %d",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(), item_condition(),
|
||||
intval(local_user()),
|
||||
intval($parents),
|
||||
intval($max_comments + 1)
|
||||
|
|
|
@ -73,11 +73,11 @@ function notes_content(&$a,$update = false) {
|
|||
$sql_extra = " AND `allow_cid` = '<" . $a->contact['id'] . ">' ";
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `total`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
FROM `item` %s
|
||||
WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
|
||||
AND `contact`.`self` AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
|
||||
$sql_extra ",
|
||||
contact_condition(), item_condition(),
|
||||
item_joins(), item_condition(),
|
||||
intval(local_user())
|
||||
|
||||
);
|
||||
|
@ -87,13 +87,12 @@ function notes_content(&$a,$update = false) {
|
|||
$a->set_pager_itemspage(40);
|
||||
}
|
||||
|
||||
$r = q("SELECT `item`.`id` AS `item_id` FROM `item`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s AND `contact`.`self`
|
||||
$r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s
|
||||
WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
|
||||
AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall`
|
||||
$sql_extra
|
||||
ORDER BY `item`.`created` DESC LIMIT %d ,%d ",
|
||||
contact_condition(), item_condition(),
|
||||
item_joins(), item_condition(),
|
||||
intval(local_user()),
|
||||
intval($a->pager['start']),
|
||||
intval($a->pager['itemspage'])
|
||||
|
@ -108,13 +107,11 @@ function notes_content(&$a,$update = false) {
|
|||
$parents_arr[] = $rr['item_id'];
|
||||
$parents_str = implode(', ', $parents_arr);
|
||||
|
||||
$r = q("SELECT %s, %s FROM `item`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
$r = q("SELECT %s FROM `item` %s
|
||||
WHERE %s AND `item`.`uid` = %d AND `item`.`parent` IN (%s)
|
||||
$sql_extra
|
||||
ORDER BY `parent` DESC, `gravity` ASC, `item`.`id` ASC ",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(), item_condition(),
|
||||
item_fieldlists(), item_joins(), item_condition(),
|
||||
intval(local_user()),
|
||||
dbesc($parents_str)
|
||||
);
|
||||
|
|
|
@ -303,13 +303,9 @@ function profile_content(&$a, $update = 0) {
|
|||
$parents_arr[] = $rr['item_id'];
|
||||
$parents_str = implode(', ', $parents_arr);
|
||||
|
||||
$items = q("SELECT %s, %s FROM `item`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
WHERE %s AND `item`.`uid` = %d
|
||||
$items = q(item_query()." AND `item`.`uid` = %d
|
||||
AND `item`.`parent` IN (%s)
|
||||
$sql_extra ",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(), item_condition(),
|
||||
intval($a->profile['profile_uid']),
|
||||
dbesc($parents_str)
|
||||
);
|
||||
|
|
|
@ -191,14 +191,12 @@ function search_content(&$a) {
|
|||
if($tag) {
|
||||
logger("Start tag search for '".$search."'", LOGGER_DEBUG);
|
||||
|
||||
$r = q("SELECT STRAIGHT_JOIN %s, %s
|
||||
$r = q("SELECT %s
|
||||
FROM `term`
|
||||
INNER JOIN `item` ON `item`.`id`=`term`.`oid`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
STRAIGHT_JOIN `item` ON `item`.`id`=`term`.`oid` %s
|
||||
WHERE %s AND (`term`.`uid` = 0 OR (`term`.`uid` = %d AND NOT `term`.`global`)) AND `term`.`otype` = %d AND `term`.`type` = %d AND `term`.`term` = '%s'
|
||||
ORDER BY term.created DESC LIMIT %d , %d ",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(), item_condition(),
|
||||
item_fieldlists(), item_joins(), item_condition(),
|
||||
intval(local_user()),
|
||||
intval(TERM_OBJ_POST), intval(TERM_HASHTAG), dbesc(protect_sprintf($search)),
|
||||
intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
|
@ -211,14 +209,13 @@ function search_content(&$a) {
|
|||
$sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
|
||||
}
|
||||
|
||||
$r = q("SELECT STRAIGHT_JOIN %s, %s
|
||||
FROM `item`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND %s
|
||||
|
||||
$r = q("SELECT %s
|
||||
FROM `item` %s
|
||||
WHERE %s AND (`item`.`uid` = 0 OR (`item`.`uid` = %s AND NOT `item`.`global`))
|
||||
$sql_extra
|
||||
GROUP BY `item`.`uri` ORDER BY `item`.`id` DESC LIMIT %d , %d",
|
||||
item_fieldlist(), contact_fieldlist(),
|
||||
contact_condition(), item_condition(),
|
||||
item_fieldlists(), item_joins(), item_condition(),
|
||||
intval(local_user()),
|
||||
intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue