X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fitems.php;h=275052c1fdb73deab8337c78b2b840f8168994ad;hb=5a0260a10fa375d34ceabd32363003f91aca18a4;hp=f334990d7766095fc6b9ffcd98249b2558b6fdcf;hpb=dc32553a1d94db877580b8bfbf08f825cc7262a1;p=friendica.git diff --git a/include/items.php b/include/items.php index f334990d77..275052c1fd 100644 --- a/include/items.php +++ b/include/items.php @@ -10,11 +10,14 @@ use Friendica\Core\PConfig; use Friendica\Core\Worker; use Friendica\Core\System; use Friendica\Database\DBM; -use Friendica\Model\GlobalContact; -use Friendica\Object\Contact; +use Friendica\Model\Contact; +use Friendica\Model\GContact; +use Friendica\Model\Group; +use Friendica\Model\User; +use Friendica\Object\Image; use Friendica\Protocol\DFRN; use Friendica\Protocol\OStatus; -use Friendica\Util\Lock; +use Friendica\Protocol\Feed; require_once 'include/bbcode.php'; require_once 'include/oembed.php'; @@ -24,10 +27,8 @@ require_once 'include/files.php'; require_once 'include/text.php'; require_once 'include/threads.php'; require_once 'include/plaintext.php'; -require_once 'include/feed.php'; require_once 'mod/share.php'; require_once 'include/enotify.php'; -require_once 'include/group.php'; function construct_verb($item) { if ($item['verb']) { @@ -41,7 +42,6 @@ function construct_verb($item) { * The purpose of this function is to apply system message length limits to * imported messages without including any embedded photos in the length */ -if (! function_exists('limit_body_size')) { function limit_body_size($body) { // logger('limit_body_size: start', LOGGER_DEBUG); @@ -124,7 +124,7 @@ function limit_body_size($body) { } else { return $body; } -}} +} function title_is_body($title, $body) { @@ -742,10 +742,10 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f * On comments the author is the better choice. */ if ($arr['parent-uri'] === $arr['uri']) { - $arr["gcontact-id"] = GlobalContact::getId(array("url" => $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'])); } } @@ -1157,6 +1157,14 @@ function item_set_last_item($arr) { 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"]))); // Is it a forum? Then we don't care about the rules from above @@ -1542,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; } @@ -1712,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))) { @@ -1879,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->isValid()) { - $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(); } } @@ -1950,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); @@ -2225,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)); }