X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fitems.php;h=275052c1fdb73deab8337c78b2b840f8168994ad;hb=27646cc4ad8d715317a2ca055b6c3318ddf555a9;hp=cffa127288de60037a16d7bd790d1797f59d3861;hpb=4ddcc77c775e42aab3bb0df3fa2942c6da345db9;p=friendica.git diff --git a/include/items.php b/include/items.php index cffa127288..275052c1fd 100644 --- a/include/items.php +++ b/include/items.php @@ -1,37 +1,34 @@ $arr['owner-link'], "network" => $arr['network'], + $arr["gcontact-id"] = GContact::getId(array("url" => $arr['owner-link'], "network" => $arr['network'], "photo" => $arr['owner-avatar'], "name" => $arr['owner-name'])); } else { - $arr["gcontact-id"] = GlobalContact::getId(array("url" => $arr['author-link'], "network" => $arr['network'], + $arr["gcontact-id"] = GContact::getId(array("url" => $arr['author-link'], "network" => $arr['network'], "photo" => $arr['author-avatar'], "name" => $arr['author-name'])); } } @@ -1155,6 +1151,19 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f * @param array $arr Contains the just posted item record */ function item_set_last_item($arr) { + // Unarchive the author + $contact = dba::select('contact', [], ['id' => $arr["author-link"]], ['limit' => 1]); + if ($contact['term-date'] > NULL_DATE) { + Contact::unmarkForArchival($contact); + } + + // Unarchive the contact if it is a toplevel posting + if ($arr["parent-uri"] === $arr["uri"]) { + $contact = dba::select('contact', [], ['id' => $arr["contact-id"]], ['limit' => 1]); + if ($contact['term-date'] > NULL_DATE) { + Contact::unmarkForArchival($contact); + } + } $update = (!$arr['private'] && (($arr["author-link"] === $arr["owner-link"]) || ($arr["parent-uri"] === $arr["uri"]))); @@ -1541,7 +1550,7 @@ function consume_feed($xml, $importer, &$contact, &$hub, $datedir = 0, $pass = 0 if ($contact['network'] === NETWORK_FEED) { if ($pass < 2) { logger("Consume feeds", LOGGER_DEBUG); - feed_import($xml, $importer, $contact, $hub); + Feed::import($xml, $importer, $contact, $hub); } return; } @@ -1683,8 +1692,8 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) { dbesc($name), dbesc($nick), dbesc($photo), - dbesc(($sharing) ? NETWORK_ZOT : NETWORK_OSTATUS), - intval(($sharing) ? CONTACT_IS_SHARING : CONTACT_IS_FOLLOWER) + dbesc(NETWORK_OSTATUS), + intval(CONTACT_IS_FOLLOWER) ); $r = q("SELECT `id`, `network` FROM `contact` WHERE `uid` = %d AND `url` = '%s' AND `pending` = 1 LIMIT 1", intval($importer['uid']), @@ -1692,7 +1701,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) { ); if (DBM::is_result($r)) { $contact_record = $r[0]; - update_contact_avatar($photo, $importer["uid"], $contact_record["id"], true); + Contact::updateAvatar($photo, $importer["uid"], $contact_record["id"], true); } /// @TODO Encapsulate this into a function/method @@ -1711,11 +1720,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) { 'hash' => $hash, 'datetime' => datetime_convert())); } - $def_gid = get_default_group($importer['uid'], $contact_record["network"]); - - if (intval($def_gid)) { - group_add_member($importer['uid'], '', $contact_record['id'], $def_gid); - } + Group::addMember(User::getDefaultGroup($importer['uid'], $contact_record["network"]), $contact_record['id']); if (($r[0]['notify-flags'] & NOTIFY_INTRO) && in_array($r[0]['page-flags'], array(PAGE_NORMAL))) { @@ -1878,11 +1883,11 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) { $width = intval($match[1]); $height = intval($match[2]); - $ph = new Photo($data, $type); - if ($ph->is_valid()) { - $ph->scaleImage(max($width, $height)); - $data = $ph->imageString(); - $type = $ph->getType(); + $Image = new Image($data, $type); + if ($Image->isValid()) { + $Image->scaleDown(max($width, $height)); + $data = $Image->asString(); + $type = $Image->getType(); } } @@ -1949,9 +1954,9 @@ function compare_permissions($obj1, $obj2) { /// @TODO type-hint is array function enumerate_permissions($obj) { $allow_people = expand_acl($obj['allow_cid']); - $allow_groups = expand_groups(expand_acl($obj['allow_gid'])); + $allow_groups = Group::expand(expand_acl($obj['allow_gid'])); $deny_people = expand_acl($obj['deny_cid']); - $deny_groups = expand_groups(expand_acl($obj['deny_gid'])); + $deny_groups = Group::expand(expand_acl($obj['deny_gid'])); $recipients = array_unique(array_merge($allow_people, $allow_groups)); $deny = array_unique(array_merge($deny_people, $deny_groups)); $recipients = array_diff($recipients, $deny); @@ -2224,7 +2229,6 @@ function drop_item($id, $interactive = true) { // Now delete them if ($parentid != "") { - $r = q("DELETE FROM `item_id` WHERE `iid` IN (%s)", dbesc($parentid)); $r = q("DELETE FROM `sign` WHERE `iid` IN (%s)", dbesc($parentid)); } @@ -2360,7 +2364,7 @@ function posted_dates($uid, $wall) { function posted_date_widget($url, $uid, $wall) { $o = ''; - if (! feature_enabled($uid, 'archives')) { + if (! Feature::isEnabled($uid, 'archives')) { return $o; }