X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fitems.php;h=14a74c8e51ea5afa0ff7e91cda3cd9aead2419b3;hb=daa1177e3a1e42b4c95e0a8759f1610942b952c7;hp=83aa82c940cc8d2c988b4f2009b924f397b044ed;hpb=32ee4ca4b1df1a98625ec363de25dd9ca014a1b6;p=friendica.git diff --git a/include/items.php b/include/items.php index 83aa82c940..14a74c8e51 100644 --- a/include/items.php +++ b/include/items.php @@ -9,6 +9,7 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Core\System; +use Friendica\Database\dba; use Friendica\Database\DBM; use Friendica\Model\Item; use Friendica\Protocol\DFRN; @@ -29,10 +30,12 @@ function add_page_info_data($data, $no_photos = false) { // It maybe is a rich content, but if it does have everything that a link has, // then treat it that way if (($data["type"] == "rich") && is_string($data["title"]) && - is_string($data["text"]) && (sizeof($data["images"]) > 0)) { + is_string($data["text"]) && !empty($data["images"])) { $data["type"] = "link"; } + $data["title"] = defaults($data, "title", ""); + if ((($data["type"] != "link") && ($data["type"] != "video") && ($data["type"] != "photo")) || ($data["title"] == $data["url"])) { return ""; } @@ -47,23 +50,23 @@ function add_page_info_data($data, $no_photos = false) { $text = "[attachment type='".$data["type"]."'"; - if ($data["text"] == "") { + if (empty($data["text"])) { $data["text"] = $data["title"]; } - if ($data["text"] == "") { + if (empty($data["text"])) { $data["text"] = $data["url"]; } - if ($data["url"] != "") { + if (!empty($data["url"])) { $text .= " url='".$data["url"]."'"; } - if ($data["title"] != "") { + if (!empty($data["title"])) { $text .= " title='".$data["title"]."'"; } - if (sizeof($data["images"]) > 0) { + if (!empty($data["images"])) { $preview = str_replace(["[", "]"], ["[", "]"], htmlentities($data["images"][0]["src"], ENT_QUOTES, 'UTF-8', false)); // if the preview picture is larger than 500 pixels then show it in a larger mode // But only, if the picture isn't higher than large (To prevent huge posts) @@ -228,7 +231,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) { * * @TODO find proper type-hints */ -function consume_feed($xml, $importer, &$contact, &$hub, $datedir = 0, $pass = 0) { +function consume_feed($xml, $importer, $contact, &$hub, $datedir = 0, $pass = 0) { if ($contact['network'] === NETWORK_OSTATUS) { if ($pass < 2) { // Test - remove before flight @@ -274,6 +277,7 @@ function consume_feed($xml, $importer, &$contact, &$hub, $datedir = 0, $pass = 0 function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') { $a = get_app(); + $r = null; if (is_array($importer)) { $r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1", @@ -321,7 +325,7 @@ function drop_items($items) { if (count($items)) { foreach ($items as $item) { - $owner = Item::deleteById($item); + $owner = Item::deleteForUser(['id' => $item], local_user()); if ($owner && !$uid) $uid = $owner; } @@ -334,17 +338,14 @@ function drop_item($id) { // locate item to be deleted - $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", - intval($id) - ); + $fields = ['id', 'uid', 'contact-id', 'deleted']; + $item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]); - if (!DBM::is_result($r)) { + if (!DBM::is_result($item)) { notice(L10n::t('Item not found.') . EOL); goaway(System::baseUrl() . '/' . $_SESSION['return_url']); } - $item = $r[0]; - if ($item['deleted']) { return 0; } @@ -363,7 +364,6 @@ function drop_item($id) { } if ((local_user() == $item['uid']) || $contact_id) { - // Check if we should do HTML-based delete confirmation if ($_REQUEST['confirm']) { //
can't take arguments in its "action" parameter @@ -393,7 +393,7 @@ function drop_item($id) { } // delete the item - Item::deleteById($item['id']); + Item::deleteForUser(['id' => $item['id']], local_user()); goaway(System::baseUrl() . '/' . $_SESSION['return_url']); //NOTREACHED @@ -430,9 +430,11 @@ function list_post_dates($uid, $wall) { $start_month = DateTimeFormat::utc($dstart, 'Y-m-d'); $end_month = DateTimeFormat::utc($dend, 'Y-m-d'); $str = day_translate(DateTimeFormat::utc($dnow, 'F')); - if (!$ret[$dyear]) { + + if (empty($ret[$dyear])) { $ret[$dyear] = []; } + $ret[$dyear][] = [$str, $end_month, $start_month]; $dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d'); }