X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fphotos.php;h=3cd8b752863b6a68b49a04113a9aa6659b8e7cd9;hb=bf0b98017decf73123891e935993f2921d3b0acf;hp=8b3dbdc759ae4294fda0bbeab81438e99d210cd4;hpb=5e7285b9ba3236e3c5b6163df323eefebbc8b20e;p=friendica.git diff --git a/mod/photos.php b/mod/photos.php index 8b3dbdc759..3cd8b75286 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Content\Feature; use Friendica\Content\Nav; +use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -22,13 +23,11 @@ use Friendica\Object\Image; use Friendica\Protocol\DFRN; use Friendica\Util\DateTimeFormat; use Friendica\Util\Map; +use Friendica\Util\Temporal; require_once 'include/items.php'; require_once 'include/acl_selectors.php'; -require_once 'include/bbcode.php'; require_once 'include/security.php'; -require_once 'include/tags.php'; -require_once 'include/threads.php'; function photos_init(App $a) { @@ -285,25 +284,12 @@ function photos_post(App $a) ); // find and delete the corresponding item with all the comments and likes/dislikes - $r = q("SELECT `id`, `parent-uri`, `visible` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d", + $r = q("SELECT `id` FROM `item` WHERE `resource-id` IN ( $str_res ) AND `uid` = %d", intval($page_owner_uid) ); if (DBM::is_result($r)) { foreach ($r as $rr) { - q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(DateTimeFormat::utcNow()), - dbesc($rr['parent-uri']), - intval($page_owner_uid) - ); - create_tags_from_itemuri($rr['parent-uri'], $page_owner_uid); - delete_thread_uri($rr['parent-uri'], $page_owner_uid); - - $drop_id = intval($rr['id']); - - // send the notification upstream/downstream as the case may be - if ($rr['visible']) { - Worker::add(PRIORITY_HIGH, "Notifier", "drop", $drop_id); - } + Item::deleteById($rr['id']); } } @@ -358,29 +344,15 @@ function photos_post(App $a) intval($page_owner_uid), dbesc($r[0]['resource-id']) ); - $i = q("SELECT `id`, `uri`, `visible` FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1", + $i = q("SELECT `id` FROM `item` WHERE `resource-id` = '%s' AND `uid` = %d LIMIT 1", dbesc($r[0]['resource-id']), intval($page_owner_uid) ); if (DBM::is_result($i)) { - q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d", - dbesc(DateTimeFormat::utcNow()), - dbesc(DateTimeFormat::utcNow()), - dbesc($i[0]['uri']), - intval($page_owner_uid) - ); - create_tags_from_itemuri($i[0]['uri'], $page_owner_uid); - delete_thread_uri($i[0]['uri'], $page_owner_uid); - - $url = System::baseUrl(); - $drop_id = intval($i[0]['id']); + Item::deleteById($i[0]['id']); // Update the photo albums cache Photo::clearAlbumCache($page_owner_uid); - - if ($i[0]['visible']) { - Worker::add(PRIORITY_HIGH, "Notifier", "drop", $drop_id); - } } } @@ -646,16 +618,9 @@ function photos_post(App $a) } $newinform .= $inform; - $r = q("UPDATE `item` SET `tag` = '%s', `inform` = '%s', `edited` = '%s', `changed` = '%s' WHERE `id` = %d AND `uid` = %d", - dbesc($newtag), - dbesc($newinform), - dbesc(DateTimeFormat::utcNow()), - dbesc(DateTimeFormat::utcNow()), - intval($item_id), - intval($page_owner_uid) - ); - create_tags_from_item($item_id); - update_thread($item_id); + $fields = ['tag' => $newtag, 'inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()]; + $condition = ['id' => $item_id]; + Item::update($fields, $condition); $best = 0; foreach ($p as $scales) { @@ -873,7 +838,7 @@ function photos_post(App $a) $smallest = 0; - $photo_hash = photo_new_resource(); + $photo_hash = Photo::newResource(); $r = Photo::store($Image, $page_owner_uid, $visitor, $photo_hash, $filename, $album, 0 , 0, $str_contact_allow, $str_group_allow, $str_contact_deny, $str_group_deny); @@ -899,7 +864,7 @@ function photos_post(App $a) // Create item container $lat = $lon = null; - if ($exif && $exif['GPS'] && Feature::isEnabled($channel_id, 'photo_location')) { + if ($exif && $exif['GPS'] && Feature::isEnabled($page_owner_uid, 'photo_location')) { $lat = Photo::getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']); $lon = Photo::getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']); } @@ -968,7 +933,6 @@ function photos_content(App $a) return; } - require_once 'include/bbcode.php'; require_once 'include/security.php'; require_once 'include/conversation.php'; @@ -1427,11 +1391,7 @@ function photos_content(App $a) ); if (local_user() && (local_user() == $link_item['uid'])) { - q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d and `uid` = %d", - intval($link_item['parent']), - intval(local_user()) - ); - update_thread($link_item['parent']); + Item::update(['unseen' => false], ['parent' => $link_item['parent']]); } if ($link_item['coord']) { @@ -1449,7 +1409,7 @@ function photos_content(App $a) if (strlen($tag_str)) { $tag_str .= ', '; } - $tag_str .= bbcode($t); + $tag_str .= BBCode::convert($t); } $tags = [L10n::t('Tags: '), $tag_str]; if ($cmd === 'edit') { @@ -1612,7 +1572,7 @@ function photos_content(App $a) $name_e = $profile_name; $title_e = $item['title']; - $body_e = bbcode($item['body']); + $body_e = BBCode::convert($item['body']); $comments .= replace_macros($template,[ '$id' => $item['item_id'], @@ -1622,7 +1582,7 @@ function photos_content(App $a) '$sparkle' => $sparkle, '$title' => $title_e, '$body' => $body_e, - '$ago' => relative_date($item['created']), + '$ago' => Temporal::getRelativeDate($item['created']), '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''), '$drop' => $drop, '$comment' => $comment