X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fitems.php;h=275052c1fdb73deab8337c78b2b840f8168994ad;hb=008c97c570ea62749a3f486b42c424365863d627;hp=4b7d277f0740750c3a0d421889e0a818a81a62b1;hpb=c847a2f9cc969c9d79141713f646dd371e898168;p=friendica.git diff --git a/include/items.php b/include/items.php index 4b7d277f07..275052c1fd 100644 --- a/include/items.php +++ b/include/items.php @@ -1,38 +1,34 @@ = 500) && ($data["images"][0]["width"] >= $data["images"][0]["height"])) { + if (!Config::get('system', 'always_show_preview') && ($data["images"][0]["width"] >= 500) + && ($data["images"][0]["width"] >= $data["images"][0]["height"])) { $text .= " image='".$preview."'"; } else { $text .= " preview='".$preview."'"; @@ -427,8 +423,8 @@ function uri_to_guid($uri, $host = "") { * @return array Item array with removed conversation data */ function store_conversation($arr) { - if (in_array($arr['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) { - $conversation = array('item-uri' => $arr['uri'], 'received' => dbm::date()); + if (in_array($arr['network'], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS)) && !empty($arr['uri'])) { + $conversation = array('item-uri' => $arr['uri'], 'received' => DBM::date()); if (isset($arr['parent-uri']) && ($arr['parent-uri'] != $arr['uri'])) { $conversation['reply-to-uri'] = $arr['parent-uri']; @@ -455,7 +451,7 @@ function store_conversation($arr) { $old_conv = dba::fetch_first("SELECT `item-uri`, `reply-to-uri`, `conversation-uri`, `conversation-href`, `protocol`, `source` FROM `conversation` WHERE `item-uri` = ?", $conversation['item-uri']); - if (dbm::is_result($old_conv)) { + if (DBM::is_result($old_conv)) { // Don't update when only the source has changed. // Only do this when there had been no source before. if ($old_conv['source'] != '') { @@ -543,9 +539,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f /// @todo Check if this is really still needed if ($arr['network'] == NETWORK_OSTATUS) { if (isset($arr['plink'])) { - $arr['plink'] = ostatus::convert_href($arr['plink']); + $arr['plink'] = OStatus::convertHref($arr['plink']); } elseif (isset($arr['uri'])) { - $arr['plink'] = ostatus::convert_href($arr['uri']); + $arr['plink'] = OStatus::convertHref($arr['uri']); } } @@ -569,7 +565,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $expire_interval = Config::get('system', 'dbclean-expire-days', 0); $r = dba::select('user', array('expire'), array('uid' => $uid), array("limit" => 1)); - if (dbm::is_result($r) && ($r['expire'] > 0) && (($r['expire'] < $expire_interval) || ($expire_interval == 0))) { + if (DBM::is_result($r) && ($r['expire'] > 0) && (($r['expire'] < $expire_interval) || ($expire_interval == 0))) { $expire_interval = $r['expire']; } @@ -595,7 +591,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f dbesc(NETWORK_DFRN), dbesc(NETWORK_OSTATUS) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { // We only log the entries with a different user id than 0. Otherwise we would have too many false positives if ($uid != 0) { logger("Item with uri ".$arr['uri']." already existed for user ".$uid." with id ".$r[0]["id"]." target network ".$r[0]["network"]." - new network: ".$arr['network']); @@ -687,20 +683,20 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f intval($arr['uid']) ); - if (!dbm::is_result($r)) + if (!DBM::is_result($r)) $r = q("SELECT `network` FROM `gcontact` WHERE `network` IN ('%s', '%s', '%s') AND `nurl` = '%s' LIMIT 1", dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS), dbesc(normalise_link($arr['author-link'])) ); - if (!dbm::is_result($r)) { + if (!DBM::is_result($r)) { $r = q("SELECT `network` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($arr['contact-id']), intval($arr['uid']) ); } - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $arr['network'] = $r[0]["network"]; } @@ -719,19 +715,19 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f * This is done only for comments (See below explanation at "gcontact-id") */ if ($arr['parent-uri'] != $arr['uri']) { - $arr["contact-id"] = get_contact($arr['author-link'], $uid); + $arr["contact-id"] = Contact::getIdForURL($arr['author-link'], $uid); } // If not present then maybe the owner was found if ($arr["contact-id"] == 0) { - $arr["contact-id"] = get_contact($arr['owner-link'], $uid); + $arr["contact-id"] = Contact::getIdForURL($arr['owner-link'], $uid); } // Still missing? Then use the "self" contact of the current user if ($arr["contact-id"] == 0) { $r = q("SELECT `id` FROM `contact` WHERE `self` AND `uid` = %d", intval($uid)); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $arr["contact-id"] = $r[0]["id"]; } } @@ -746,28 +742,28 @@ 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"] = get_gcontact_id(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"] = get_gcontact_id(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'])); } } if ($arr["author-id"] == 0) { - $arr["author-id"] = get_contact($arr["author-link"], 0); + $arr["author-id"] = Contact::getIdForURL($arr["author-link"], 0); } - if (blockedContact($arr["author-id"])) { + if (Contact::isBlocked($arr["author-id"])) { logger('Contact '.$arr["author-id"].' is blocked, item '.$arr["uri"].' will not be stored'); return 0; } if ($arr["owner-id"] == 0) { - $arr["owner-id"] = get_contact($arr["owner-link"], 0); + $arr["owner-id"] = Contact::getIdForURL($arr["owner-link"], 0); } - if (blockedContact($arr["owner-id"])) { + if (Contact::isBlocked($arr["owner-id"])) { logger('Contact '.$arr["owner-id"].' is blocked, item '.$arr["uri"].' will not be stored'); return 0; } @@ -778,7 +774,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $r = q("SELECT `guid` FROM `item` WHERE `guid` = '%s' AND `network` = '%s' AND `uid` = '%d' LIMIT 1", dbesc($arr['guid']), dbesc($arr['network']), intval($arr['uid'])); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { logger('found item with guid '.$arr['guid'].' for user '.$arr['uid'].' on network '.$arr['network'], LOGGER_DEBUG); return 0; } @@ -807,7 +803,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f intval($arr['uid']) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { // is the new message multi-level threaded? // even though we don't support it now, preserve the info @@ -822,7 +818,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f intval($arr['uid']) ); - if (dbm::is_result($z)) { + if (DBM::is_result($z)) { $r = $z; } } @@ -857,7 +853,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f // If its a post from myself then tag the thread as "mention" logger("item_store: Checking if parent ".$parent_id." has to be tagged as mention for user ".$arr['uid'], LOGGER_DEBUG); $u = q("SELECT `nickname` FROM `user` WHERE `uid` = %d", intval($arr['uid'])); - if (dbm::is_result($u)) { + if (DBM::is_result($u)) { $a = get_app(); $self = normalise_link(System::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); @@ -891,7 +887,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f dbesc(NETWORK_DFRN), intval($arr['uid']) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { logger('duplicated item with the same uri found. '.print_r($arr,true)); return 0; } @@ -902,7 +898,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f dbesc($arr['guid']), intval($arr['uid']) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { logger('duplicated item with the same guid found. '.print_r($arr,true)); return 0; } @@ -915,7 +911,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f intval($arr['contact-id']), intval($arr['uid']) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { logger('duplicated item with the same body found. '.print_r($arr,true)); return 0; } @@ -930,7 +926,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f } else { $isglobal = q("SELECT `global` FROM `item` WHERE `uid` = 0 AND `uri` = '%s'", dbesc($arr["uri"])); - $arr["global"] = (dbm::is_result($isglobal) && count($isglobal) > 0); + $arr["global"] = (DBM::is_result($isglobal) && count($isglobal) > 0); } // ACL settings @@ -972,7 +968,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f */ if ($arr["uid"] == 0) { $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = 0 LIMIT 1", dbesc(trim($arr['uri']))); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { logger('Global item already stored. URI: '.$arr['uri'].' on network '.$arr['network'], LOGGER_DEBUG); return 0; } @@ -984,7 +980,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $r = dba::insert('item', $arr); // When the item was successfully stored we fetch the ID of the item. - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $current_post = dba::lastInsertId(); } else { // This can happen - for example - if there are locking timeouts. @@ -1025,7 +1021,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f dbesc($arr['network']) ); - if (!dbm::is_result($r)) { + if (!DBM::is_result($r)) { // This shouldn't happen, since COUNT always works when the database connection is there. logger("We couldn't count the stored entries. Very strange ..."); dba::rollback(); @@ -1062,7 +1058,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f // update the commented timestamp on the parent // 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) || !Config::get("system", "like_no_comment")) { dba::update('item', array('commented' => datetime_convert(), 'changed' => datetime_convert()), array('id' => $parent_id)); } else { dba::update('item', array('changed' => datetime_convert()), array('id' => $parent_id)); @@ -1092,7 +1088,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f if (!$deleted && !$dontcache) { $r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post)); - if ((dbm::is_result($r)) && (count($r) == 1)) { + if ((DBM::is_result($r)) && (count($r) == 1)) { if ($notify) { call_hooks('post_local_end', $r[0]); } else { @@ -1139,7 +1135,7 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f check_item_notification($current_post, $uid); if ($notify) { - Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "notifier", $notify_type, $current_post); + Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), "Notifier", $notify_type, $current_post); } return $current_post; @@ -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"]))); @@ -1162,7 +1171,7 @@ function item_set_last_item($arr) { if (!$update && ($arr["network"] == NETWORK_DFRN) && ($arr["parent-uri"] === $arr["uri"])) { $isforum = q("SELECT `forum` FROM `contact` WHERE `id` = %d AND `forum`", intval($arr['contact-id'])); - if (dbm::is_result($isforum)) { + if (DBM::is_result($isforum)) { $update = true; } } @@ -1254,7 +1263,7 @@ function item_body_set_hashtags(&$item) { function get_item_guid($id) { $r = q("SELECT `guid` FROM `item` WHERE `id` = %d LIMIT 1", intval($id)); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { return $r[0]["guid"]; } else { /// @TODO This else-block can be elimited again @@ -1276,7 +1285,7 @@ function get_item_id($guid, $uid = 0) { $r = q("SELECT `item`.`id`, `user`.`nickname` FROM `item` INNER JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `item`.`moderated` = 0 AND `item`.`guid` = '%s' AND `item`.`uid` = %d", dbesc($guid), intval($uid)); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $id = $r[0]["id"]; $nick = $r[0]["nickname"]; } @@ -1290,7 +1299,7 @@ function get_item_id($guid, $uid = 0) { AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `item`.`guid` = '%s'", dbesc($guid)); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $id = $r[0]["id"]; $nick = $r[0]["nickname"]; } @@ -1328,7 +1337,7 @@ function tag_deliver($uid, $item_id) { intval($uid) ); - if (! dbm::is_result($u)) { + if (! DBM::is_result($u)) { return; } @@ -1340,7 +1349,7 @@ function tag_deliver($uid, $item_id) { intval($item_id), intval($uid) ); - if (! dbm::is_result($i)) { + if (! DBM::is_result($i)) { return; } @@ -1397,7 +1406,7 @@ function tag_deliver($uid, $item_id) { $c = q("SELECT `name`, `url`, `thumb` FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($u[0]['uid']) ); - if (! dbm::is_result($c)) { + if (! DBM::is_result($c)) { return; } @@ -1422,7 +1431,7 @@ function tag_deliver($uid, $item_id) { ); update_thread($item_id); - Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), 'notifier', 'tgroup', $item_id); + Worker::add(array('priority' => PRIORITY_HIGH, 'dont_fork' => true), 'Notifier', 'tgroup', $item_id); } @@ -1442,7 +1451,7 @@ function tgroup_check($uid, $item) { $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid) ); - if (! dbm::is_result($u)) { + if (! DBM::is_result($u)) { return false; } @@ -1533,7 +1542,7 @@ function consume_feed($xml, $importer, &$contact, &$hub, $datedir = 0, $pass = 0 //$tempfile = tempnam(get_temppath(), "ostatus2"); //file_put_contents($tempfile, $xml); logger("Consume OStatus messages ", LOGGER_DEBUG); - ostatus::import($xml, $importer, $contact, $hub); + OStatus::import($xml, $importer, $contact, $hub); } return; } @@ -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; } @@ -1561,9 +1570,9 @@ function consume_feed($xml, $importer, &$contact, &$hub, $datedir = 0, $pass = 0 WHERE `contact`.`id` = %d AND `user`.`uid` = %d", dbesc($contact["id"]), dbesc($importer["uid"]) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { logger("Now import the DFRN feed"); - dfrn::import($xml, $r[0], true); + DFRN::import($xml, $r[0], true); return; } } @@ -1601,7 +1610,7 @@ function item_is_remote_self($contact, &$datarray) { if ($contact['remote_self'] == 2) { $r = q("SELECT `id`,`url`,`name`,`thumb` FROM `contact` WHERE `uid` = %d AND `self`", intval($contact['uid'])); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { $datarray['contact-id'] = $r[0]["id"]; $datarray['owner-name'] = $r[0]["name"]; @@ -1683,16 +1692,16 @@ 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']), dbesc($url) ); - if (dbm::is_result($r)) { + 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 @@ -1700,7 +1709,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) { intval($importer['uid']) ); - if (dbm::is_result($r) && !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) { + if (DBM::is_result($r) && !in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) { // create notification $hash = random_string(); @@ -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))) { @@ -1736,7 +1741,7 @@ function new_follower($importer, $contact, $datarray, $item, $sharing = false) { )); } - } elseif (dbm::is_result($r) && in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) { + } elseif (DBM::is_result($r) && in_array($r[0]['page-flags'], array(PAGE_SOAPBOX, PAGE_FREELOVE, PAGE_COMMUNITY))) { $r = q("UPDATE `contact` SET `pending` = 0 WHERE `uid` = %d AND `url` = '%s' AND `pending` LIMIT 1", intval($importer['uid']), dbesc($url) @@ -1751,7 +1756,7 @@ function lose_follower($importer, $contact, array $datarray = array(), $item = " if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) { dba::update('contact', array('rel' => CONTACT_IS_SHARING), array('id' => $contact['id'])); } else { - contact_remove($contact['id']); + Contact::remove($contact['id']); } } @@ -1760,7 +1765,7 @@ function lose_sharer($importer, $contact, array $datarray = array(), $item = "") if (($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) { dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id'])); } else { - contact_remove($contact['id']); + Contact::remove($contact['id']); } } @@ -1779,11 +1784,11 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') { * through the direct Diaspora protocol. If we try and use * the feed, we'll get duplicates. So don't. */ - if ((! dbm::is_result($r)) || $contact['network'] === NETWORK_DIASPORA) { + if ((! DBM::is_result($r)) || $contact['network'] === NETWORK_DIASPORA) { return; } - $push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id']; + $push_url = Config::get('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id']; // Use a single verify token, even if multiple hubs $verify_token = ((strlen($contact['hub-verify'])) ? $contact['hub-verify'] : random_string()); @@ -1806,7 +1811,7 @@ function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') { function fix_private_photos($s, $uid, $item = null, $cid = 0) { - if (get_config('system','disable_embedded')) { + if (Config::get('system','disable_embedded')) { return $s; } @@ -1845,7 +1850,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) { intval($uid) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { /* * Check to see if we should replace this photo link with an embedded image * 1. No need to do so if the photo is public @@ -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); @@ -1991,7 +1996,7 @@ function item_expire($uid, $days, $network = "", $force = false) { * $expire_network_only = save your own wall posts * and just expire conversations started by others */ - $expire_network_only = get_pconfig($uid,'expire', 'network_only'); + $expire_network_only = PConfig::get($uid,'expire', 'network_only'); $sql_extra = ((intval($expire_network_only)) ? " AND wall = 0 " : ""); if ($network != "") { @@ -2016,26 +2021,20 @@ function item_expire($uid, $days, $network = "", $force = false) { intval($days) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { return; } - $expire_items = get_pconfig($uid, 'expire', 'items'); - $expire_items = (($expire_items === false) ? 1 : intval($expire_items)); // default if not set: 1 + $expire_items = PConfig::get($uid, 'expire', 'items', 1); // Forcing expiring of items - but not notes and marked items if ($force) { $expire_items = true; } - $expire_notes = get_pconfig($uid, 'expire', 'notes'); - $expire_notes = (($expire_notes === false) ? 1 : intval($expire_notes)); // default if not set: 1 - - $expire_starred = get_pconfig($uid, 'expire', 'starred'); - $expire_starred = (($expire_starred === false) ? 1 : intval($expire_starred)); // default if not set: 1 - - $expire_photos = get_pconfig($uid, 'expire', 'photos'); - $expire_photos = (($expire_photos === false) ? 0 : intval($expire_photos)); // default if not set: 0 + $expire_notes = PConfig::get($uid, 'expire', 'notes', 1); + $expire_starred = PConfig::get($uid, 'expire', 'starred', 1); + $expire_photos = PConfig::get($uid, 'expire', 'photos', 0); logger('User '.$uid.': expire: # items=' . count($r). "; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos"); @@ -2062,7 +2061,7 @@ function item_expire($uid, $days, $network = "", $force = false) { drop_item($item['id'], false); } - Worker::add(array('priority' => PRIORITY_LOW, 'dont_fork' => true), "notifier", "expire", $uid); + Worker::add(array('priority' => PRIORITY_LOW, 'dont_fork' => true), "Notifier", "expire", $uid); } /// @TODO type-hint is array @@ -2084,7 +2083,7 @@ function drop_items($items) { // multiple threads may have been deleted, send an expire notification if ($uid) { - Worker::add(array('priority' => PRIORITY_LOW, 'dont_fork' => true), "notifier", "expire", $uid); + Worker::add(array('priority' => PRIORITY_LOW, 'dont_fork' => true), "Notifier", "expire", $uid); } } @@ -2099,7 +2098,7 @@ function drop_item($id, $interactive = true) { intval($id) ); - if (! dbm::is_result($r)) { + if (! DBM::is_result($r)) { if (! $interactive) { return 0; } @@ -2129,7 +2128,7 @@ function drop_item($id, $interactive = true) { } - if ((local_user() == $item['uid']) || ($contact_id) || (! $interactive)) { + if ((local_user() == $item['uid']) || $contact_id || !$interactive) { // Check if we should do HTML-based delete confirmation if ($_REQUEST['confirm']) { @@ -2196,30 +2195,18 @@ function drop_item($id, $interactive = true) { * generate a resource-id and therefore aren't intimately linked to the item. */ if (strlen($item['resource-id'])) { - q("DELETE FROM `photo` WHERE `resource-id` = '%s' AND `uid` = %d ", - dbesc($item['resource-id']), - intval($item['uid']) - ); - // ignore the result + dba::delete('photo', array('resource-id' => $item['resource-id'], 'uid' => $item['uid'])); } // If item is a link to an event, nuke the event record. if (intval($item['event-id'])) { - q("DELETE FROM `event` WHERE `id` = %d AND `uid` = %d", - intval($item['event-id']), - intval($item['uid']) - ); - // ignore the result + dba::delete('event', array('id' => $item['event-id'], 'uid' => $item['uid'])); } // If item has attachments, drop them foreach (explode(", ", $item['attach']) as $attach) { preg_match("|attach/(\d+)|", $attach, $matches); - q("DELETE FROM `attach` WHERE `id` = %d AND `uid` = %d", - intval($matches[1]), - local_user() - ); - // ignore the result + dba::delete('attach', array('id' => $matches[1], 'uid' => $item['uid'])); } // The new code splits the queries since the mysql optimizer really has bad problems with subqueries @@ -2242,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)); } @@ -2266,7 +2252,7 @@ function drop_item($id, $interactive = true) { dbesc($item['parent-uri']), intval($item['uid']) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { dba::update('item', array('last-child' => true), array('id' => $r[0]['id'])); } } @@ -2276,7 +2262,7 @@ function drop_item($id, $interactive = true) { $drop_id = intval($item['id']); $priority = ($interactive ? PRIORITY_HIGH : PRIORITY_LOW); - Worker::add(array('priority' => $priority, 'dont_fork' => true), "notifier", "drop", $drop_id); + Worker::add(array('priority' => $priority, 'dont_fork' => true), "Notifier", "drop", $drop_id); if (! $interactive) { return $owner; @@ -2303,7 +2289,7 @@ function first_post_date($uid, $wall = false) { intval($uid), intval($wall ? 1 : 0) ); - if (dbm::is_result($r)) { + if (DBM::is_result($r)) { // logger('first_post_date: ' . $r[0]['id'] . ' ' . $r[0]['created'], LOGGER_DATA); return substr(datetime_convert('',date_default_timezone_get(), $r[0]['created']),0,10); } @@ -2378,25 +2364,25 @@ 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; } // For former Facebook folks that left because of "timeline" /* * @TODO old-lost code? - if ($wall && intval(get_pconfig($uid, 'system', 'no_wall_archive_widget'))) + if ($wall && intval(PConfig::get($uid, 'system', 'no_wall_archive_widget'))) return $o; */ - $visible_years = get_pconfig($uid,'system','archive_visible_years'); + $visible_years = PConfig::get($uid,'system','archive_visible_years'); if (! $visible_years) { $visible_years = 5; } $ret = list_post_dates($uid, $wall); - if (! dbm::is_result($ret)) { + if (! DBM::is_result($ret)) { return $o; }