}
if ($a->argc > 3 && $a->argv[2] === 'album') {
+ if (!Strings::isHex($a->argv[3])) {
+ $a->internalRedirect('photos/' . $a->data['user']['nickname'] . '/album');
+ }
$album = hex2bin($a->argv[3]);
if ($album === L10n::t('Profile Photos') || $album === 'Contact Photos' || $album === L10n::t('Contact Photos')) {
return;
}
- $selname = $datum ? hex2bin($datum) : '';
+ $selname = Strings::isHex($datum) ? hex2bin($datum) : '';
$albumselect = '';
// Display a single photo album
if ($datatype === 'album') {
+ // if $datum is not a valid hex, redirect to the default page
+ if (!Strings::isHex($datum)) {
+ $a->internalRedirect('photos/' . $a->data['user']['nickname']. '/album');
+ }
$album = hex2bin($datum);
$total = 0;
'filename' => $hires['filename'],
];
+ $map = null;
+ $link_item = [];
+ $total = 0;
+
// Do we have an item for this photo?
// FIXME! - replace following code to display the conversation with our normal
$linked_items = q("SELECT `id` FROM `item` WHERE `resource-id` = '%s' $sql_extra LIMIT 1",
DBA::escape($datum)
);
-
- $map = null;
- $link_item = [];
- $total = 0;
-
if (DBA::isResult($linked_items)) {
// This is a workaround to not being forced to rewrite the while $sql_extra handling
$link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
+ }
+ if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
$condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
$total = DBA::count('item', $condition);
$result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
$items = Item::inArray($result);
- if (local_user() && (local_user() == $link_item['uid'])) {
+ if (local_user() == $link_item['uid']) {
Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
}
+ }
- if ($link_item['coord']) {
- $map = Map::byCoordinates($link_item['coord']);
- }
+ if (!empty($link_item['coord'])) {
+ $map = Map::byCoordinates($link_item['coord']);
}
$tags = null;
- if (count($linked_items) && strlen($link_item['tag'])) {
+ if (!empty($link_item['id']) && !empty($link_item['tag'])) {
$arr = explode(',', $link_item['tag']);
// parse tags and add links
$tag_arr = [];
foreach ($arr as $tag) {
$tag_arr[] = [
'name' => BBCode::convert($tag),
- 'removeurl' => '/tagrm/'.$link_item['id'] . '/' . bin2hex($tag)
+ 'removeurl' => '/tagrm/' . $link_item['id'] . '/' . bin2hex($tag)
];
}
$tags = ['title' => L10n::t('Tags: '), 'tags' => $tag_arr];
'$permissions' => L10n::t('Permissions'),
'$aclselect' => $aclselect_e,
- '$item_id' => defaults($link_item, 'id', 0),
+ '$item_id' => $link_item['id'] ?? 0,
'$submit' => L10n::t('Submit'),
'$delete' => L10n::t('Delete Photo'),
$paginate = '';
$responses = '';
- if (count($linked_items)) {
+ if (!empty($link_item['id']) && !empty($link_item['uri'])) {
$cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
$tpl = Renderer::getMarkupTemplate('photo_item.tpl');
$return_path = $a->cmd;
'$title' => $title_e,
'$body' => $body_e,
'$ago' => Temporal::getRelativeDate($item['created']),
- '$indent' => (($item['parent'] != $item['item_id']) ? ' comment' : ''),
+ '$indent' => (($item['parent'] != $item['id']) ? ' comment' : ''),
'$drop' => $drop,
'$comment' => $comment
]);
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_path,
- '$id' => $item['item_id'],
+ '$id' => $item['id'],
'$parent' => $item['parent'],
'$profile_uid' => $owner_uid,
'$mylink' => $contact['url'],