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;
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) {
);
// 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']);
}
}
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);
- }
}
}
}
$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) {
$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);
// 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']);
}
return;
}
- require_once 'include/bbcode.php';
require_once 'include/security.php';
require_once 'include/conversation.php';
);
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']) {
if (strlen($tag_str)) {
$tag_str .= ', ';
}
- $tag_str .= bbcode($t);
+ $tag_str .= BBCode::convert($t);
}
$tags = [L10n::t('Tags: '), $tag_str];
if ($cmd === 'edit') {
$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'],
'$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