use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Profile;
+use Friendica\Model\User;
use Friendica\Network\Probe;
use Friendica\Object\Image;
use Friendica\Protocol\DFRN;
killme();
}
- $r = q("SELECT `contact`.*, `user`.`nickname` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
- WHERE `user`.`uid` = %d AND `self` = 1 LIMIT 1",
- intval($page_owner_uid)
- );
+ $owner_record = User::getOwnerDataById($page_owner_uid);
- if (!DBM::is_result($r)) {
+ if (!$owner_record) {
notice(L10n::t('Contact information unavailable') . EOL);
logger('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
killme();
}
- $owner_record = $r[0];
-
if ($a->argc > 3 && $a->argv[2] === 'album') {
$album = hex2bin($a->argv[3]);
);
// find and delete the corresponding item with all the comments and likes/dislikes
- $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) {
- Item::deleteById($rr['id']);
- }
- }
+ Item::deleteForUser(['resource-id' => $res, 'uid' => $page_owner_uid], $page_owner_uid);
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);
intval($page_owner_uid),
dbesc($r[0]['resource-id'])
);
- $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)) {
- Item::deleteById($i[0]['id']);
- // Update the photo albums cache
- Photo::clearAlbumCache($page_owner_uid);
- }
+ Item::deleteForUser(['resource-id' => $r[0]['resource-id'], 'uid' => $page_owner_uid], $page_owner_uid);
+
+ // Update the photo albums cache
+ Photo::clearAlbumCache($page_owner_uid);
}
goaway('photos/' . $a->data['user']['nickname']);
if (!$item_id) {
// Create item container
$title = '';
- $uri = item_new_uri($a->get_hostname(),$page_owner_uid);
+ $uri = Item::newURI($page_owner_uid);
$arr = [];
$arr['guid'] = get_guid(32);
}
if ($item_id) {
- $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
- intval($item_id),
- intval($page_owner_uid)
- );
+ $item = Item::selectFirst(['tag', 'inform'], ['id' => $item_id, 'uid' => $page_owner_uid]);
}
- if (DBM::is_result($r)) {
- $old_tag = $r[0]['tag'];
- $old_inform = $r[0]['inform'];
+ if (DBM::is_result($item)) {
+ $old_tag = $item['tag'];
+ $old_inform = $item['inform'];
}
if (strlen($rawtags)) {
if (count($taginfo)) {
foreach ($taginfo as $tagged) {
- $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
+ $uri = Item::newURI($page_owner_uid);
$arr = [];
$arr['guid'] = get_guid(32);
$smallest = 2;
}
- $uri = item_new_uri($a->get_hostname(), $page_owner_uid);
+ $uri = Item::newURI($page_owner_uid);
// Create item container
$lat = $lon = null;
if (!Config::get('system', 'no_count', false)) {
$order_field = defaults($_GET, 'order', '');
if ($order_field === 'posted') {
- if (!Config::get('system', 'no_count', false)) {
- if ($_GET['order'] === 'posted') {
$order = 'ASC';
} else {
$order = 'DESC';
if (count($ph) == 1) {
$hires = $lores = $ph[0];
}
+
if (count($ph) > 1) {
if ($ph[1]['scale'] == 2) {
// original is 640 or less, we can display it directly
continue;
}
- $redirect_url = 'redir/' . $item['cid'];
-
- if (local_user() && ($item['contact-uid'] == local_user())
- && ($item['network'] == NETWORK_DFRN) && !$item['self']) {
- $profile_url = $redirect_url;
+ $profile_url = Contact::MagicLinkById($item['cid']);
+ if (strpos($profile_url, 'redir/') === 0) {
$sparkle = ' sparkle';
} else {
- $profile_url = $item['url'];
$sparkle = '';
}