1
0
Fork 0

Several updates are transformed as well

This commit is contained in:
Michael 2017-08-10 04:31:46 +00:00
parent f1a57dd9c6
commit bd8efb7f92

View file

@ -844,7 +844,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
$self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']); $self = normalise_link(App::get_baseurl() . '/profile/' . $u[0]['nickname']);
logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG); logger("item_store: 'myself' is ".$self." for parent ".$parent_id." checking against ".$arr['author-link']." and ".$arr['owner-link'], LOGGER_DEBUG);
if ((normalise_link($arr['author-link']) == $self) || (normalise_link($arr['owner-link']) == $self)) { if ((normalise_link($arr['author-link']) == $self) || (normalise_link($arr['owner-link']) == $self)) {
q("UPDATE `thread` SET `mention` = 1 WHERE `iid` = %d", intval($parent_id)); dba::update('thread', array('mention' => true), array('iid' => $parent_id));
logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG); logger("item_store: tagged thread ".$parent_id." as mention for user ".$self, LOGGER_DEBUG);
} }
} }
@ -908,7 +908,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
$arr["global"] = true; $arr["global"] = true;
// Set the global flag on all items if this was a global item entry // Set the global flag on all items if this was a global item entry
q("UPDATE `item` SET `global` = 1 WHERE `uri` = '%s'", dbesc($arr["uri"])); dba::update('item', array('global' => true), array('uri' => $arr["uri"]));
} else { } else {
$isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"])); $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"]));
@ -1039,10 +1039,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
} }
// Set parent id // Set parent id
$r = q("UPDATE `item` SET `parent` = %d WHERE `id` = %d", $r = dba::update('item', array('parent' => $parent_id), array('id' => $current_post));
intval($parent_id),
intval($current_post)
);
$arr['id'] = $current_post; $arr['id'] = $current_post;
$arr['parent'] = $parent_id; $arr['parent'] = $parent_id;
@ -1050,16 +1047,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f
// update the commented timestamp on the parent // update the commented timestamp on the parent
// Only update "commented" if it is really a comment // Only update "commented" if it is really a comment
if (($arr['verb'] == ACTIVITY_POST) || !get_config("system", "like_no_comment")) { if (($arr['verb'] == ACTIVITY_POST) || !get_config("system", "like_no_comment")) {
q("UPDATE `item` SET `commented` = '%s', `changed` = '%s' WHERE `id` = %d", dba::update('item', array('commented' => datetime_convert(), 'changed' => datetime_convert()), array('id' => $parent_id));
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($parent_id)
);
} else { } else {
q("UPDATE `item` SET `changed` = '%s' WHERE `id` = %d", dba::update('item', array('changed' => datetime_convert()), array('id' => $parent_id));
dbesc(datetime_convert()),
intval($parent_id)
);
} }
if ($dsprsig) { if ($dsprsig) {
@ -1162,26 +1152,17 @@ function item_set_last_item($arr) {
} }
if ($update) { if ($update) {
q("UPDATE `contact` SET `success_update` = '%s', `last-item` = '%s' WHERE `id` = %d", dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
dbesc($arr['received']), array('id' => $arr['contact-id']));
dbesc($arr['received']),
intval($arr['contact-id'])
);
} }
// Now do the same for the system wide contacts with uid=0 // Now do the same for the system wide contacts with uid=0
if (!$arr['private']) { if (!$arr['private']) {
q("UPDATE `contact` SET `success_update` = '%s', `last-item` = '%s' WHERE `id` = %d", dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
dbesc($arr['received']), array('id' => $arr['owner-id']));
dbesc($arr['received']),
intval($arr['owner-id'])
);
if ($arr['owner-id'] != $arr['author-id']) { if ($arr['owner-id'] != $arr['author-id']) {
q("UPDATE `contact` SET `success_update` = '%s', `last-item` = '%s' WHERE `id` = %d", dba::update('contact', array('success_update' => $arr['received'], 'last-item' => $arr['received']),
dbesc($arr['received']), array('id' => $arr['author-id']));
dbesc($arr['received']),
intval($arr['author-id'])
);
} }
} }
} }
@ -1487,7 +1468,7 @@ function tgroup_check($uid, $item) {
* *
* @todo fix type-hints (both array) * @todo fix type-hints (both array)
*/ */
function edited_timestamp_is_newer ($existing, $update) { function edited_timestamp_is_newer($existing, $update) {
if (!x($existing, 'edited') || !$existing['edited']) { if (!x($existing, 'edited') || !$existing['edited']) {
return true; return true;
} }
@ -1660,11 +1641,8 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
if (is_array($contact)) { if (is_array($contact)) {
if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING) if (($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) { || ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
$r = q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d", $r = dba::update('contact', array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
intval(CONTACT_IS_FRIEND), array('id' => $contact['id'], 'uid' => $importer['uid']));
intval($contact['id']),
intval($importer['uid'])
);
} }
// send email notification to owner? // send email notification to owner?
} else { } else {
@ -1747,10 +1725,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) {
function lose_follower($importer, $contact, array $datarray = array(), $item = "") { function lose_follower($importer, $contact, array $datarray = array(), $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) { if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d", dba::update('contact', array('rel' => CONTACT_IS_SHARING), array('id' => $contact['id']));
intval(CONTACT_IS_SHARING),
intval($contact['id'])
);
} else { } else {
contact_remove($contact['id']); contact_remove($contact['id']);
} }
@ -1759,10 +1734,7 @@ function lose_follower($importer, $contact, array $datarray = array(), $item = "
function lose_sharer($importer, $contact, array $datarray = array(), $item = "") { function lose_sharer($importer, $contact, array $datarray = array(), $item = "") {
if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) { if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d", dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id']));
intval(CONTACT_IS_FOLLOWER),
intval($contact['id'])
);
} else { } else {
contact_remove($contact['id']); contact_remove($contact['id']);
} }
@ -1797,10 +1769,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') {
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token); logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) { if (!strlen($contact['hub-verify']) || ($contact['hub-verify'] != $verify_token)) {
$r = q("UPDATE `contact` SET `hub-verify` = '%s' WHERE `id` = %d", $r = dba::update('contact', array('hub-verify' => $verify_token), array('id' => $contact['id']));
dbesc($verify_token),
intval($contact['id'])
);
} }
post_url($url, $params); post_url($url, $params);
@ -2168,13 +2137,12 @@ function drop_item($id, $interactive = true) {
} }
logger('delete item: ' . $item['id'], LOGGER_DEBUG); logger('delete item: ' . $item['id'], LOGGER_DEBUG);
// delete the item
$r = q("UPDATE `item` SET `deleted` = 1, `title` = '', `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d", // delete the item
dbesc(datetime_convert()), $r = dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
dbesc(datetime_convert()), 'edited' => datetime_convert(), 'changed' => datetime_convert()),
intval($item['id']) array('id' => $item['id']));
);
create_tags_from_item($item['id']); create_tags_from_item($item['id']);
create_files_from_item($item['id']); create_files_from_item($item['id']);
delete_thread($item['id'], $item['parent-uri']); delete_thread($item['id'], $item['parent-uri']);
@ -2257,33 +2225,26 @@ function drop_item($id, $interactive = true) {
// If it's the parent of a comment thread, kill all the kids // If it's the parent of a comment thread, kill all the kids
if ($item['uri'] == $item['parent-uri']) { if ($item['uri'] == $item['parent-uri']) {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' $r = dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
WHERE `parent-uri` = '%s' AND `uid` = %d ", 'edited' => datetime_convert(), 'changed' => datetime_convert()),
dbesc(datetime_convert()), array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid']));
dbesc(datetime_convert()),
dbesc($item['parent-uri']),
intval($item['uid'])
);
create_tags_from_itemuri($item['parent-uri'], $item['uid']); create_tags_from_itemuri($item['parent-uri'], $item['uid']);
create_files_from_itemuri($item['parent-uri'], $item['uid']); create_files_from_itemuri($item['parent-uri'], $item['uid']);
delete_thread_uri($item['parent-uri'], $item['uid']); delete_thread_uri($item['parent-uri'], $item['uid']);
// ignore the result // ignore the result
} else { } else {
// ensure that last-child is set in case the comment that had it just got wiped. // ensure that last-child is set in case the comment that had it just got wiped.
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", dba::update('item', array('last-child' => false, 'changed' => datetime_convert()),
dbesc(datetime_convert()), array('parent-uri' => $item['parent-uri'], 'uid' => $item['uid']));
dbesc($item['parent-uri']),
intval($item['uid'])
);
// who is the last child now? // who is the last child now?
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1", $r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1",
dbesc($item['parent-uri']), dbesc($item['parent-uri']),
intval($item['uid']) intval($item['uid'])
); );
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d", dba::update('item', array('last-child' => true), array('id' => $r[0]['id']));
intval($r[0]['id'])
);
} }
} }