}
if (DI::args()->getArgc() > 3 && DI::args()->getArgv()[2] === 'album') {
- if (!Strings::isHex(DI::args()->getArgv()[3])) {
+ if (!Strings::isHex(DI::args()->getArgv()[3] ?? '')) {
DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
}
$album = hex2bin(DI::args()->getArgv()[3]);
}
}
+ /*
+ * We create a wall item for every photo, but we don't want to
+ * overwhelm the data stream with a hundred newly uploaded photos.
+ * So we will make the first photo uploaded to this album in the last several hours
+ * visible by default, the rest will become visible over time when and if
+ * they acquire comments, likes, dislikes, and/or tags
+ */
+
+ $r = Photo::selectToArray([], ['`album` = ? AND `uid` = ? AND `created` > ?', $album, $page_owner_uid, DateTimeFormat::utc('now - 3 hours')]);
+
+ if (!DBA::isResult($r) || ($album == DI::l10n()->t(Photo::PROFILE_PHOTOS))) {
+ $visible = 1;
+ } else {
+ $visible = 0;
+ }
+
+ if (!empty($_REQUEST['not_visible']) && $_REQUEST['not_visible'] !== 'false') {
+ $visible = 0;
+ }
+
$ret = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''];
Hook::callAll('photo_post_file', $ret);
$arr['allow_gid'] = $str_group_allow;
$arr['deny_cid'] = $str_contact_deny;
$arr['deny_gid'] = $str_group_deny;
- $arr['visible'] = 0;
+ $arr['visible'] = $visible;
$arr['origin'] = 1;
$arr['body'] = '[url=' . DI::baseUrl() . '/photos/' . $owner_record['nickname'] . '/image/' . $resource_id . ']'
return;
}
- $selname = Strings::isHex($datum) ? hex2bin($datum) : '';
+ $selname = (!is_null($datum) && 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)) {
+ if (is_null($datum) || !Strings::isHex($datum)) {
DI::baseUrl()->redirect('photos/' . $user['nickname']. '/album');
}
$album = hex2bin($datum);
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
$order_field = $_GET['order'] ?? '';
- if ($order_field === 'posted') {
+ if ($order_field === 'created') {
$order = 'ASC';
} else {
$order = 'DESC';
$drop = [DI::l10n()->t('Drop Album'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '/drop'];
}
- if ($order_field === 'posted') {
+ if ($order_field === 'created') {
$order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
} else {
- $order = [DI::l10n()->t('Show Oldest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '?order=posted', 'newest'];
+ $order = [DI::l10n()->t('Show Oldest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '?order=created', 'newest'];
}
$photos = [];
'id' => $rr['id'],
'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id']
- . ($order_field === 'posted' ? '?order=posted' : ''),
+ . ($order_field === 'created' ? '?order=created' : ''),
'title' => DI::l10n()->t('View Photo'),
'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
'alt' => $imgalt_e,
if ($cmd === 'view' && !DI::config()->get('system', 'no_count', false)) {
$order_field = $_GET['order'] ?? '';
- if ($order_field === 'posted') {
+ if ($order_field === 'created') {
$params = ['order' => [$order_field]];
} elseif (!empty($order_field)) {
$params = ['order' => [$order_field => true]];
}
if (!is_null($prv)) {
- $prevlink = 'photos/' . $user['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : '');
+ $prevlink = 'photos/' . $user['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . ($order_field === 'created' ? '?order=created' : '');
}
if (!is_null($nxt)) {
- $nextlink = 'photos/' . $user['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'posted' ? '?order=posted' : '');
+ $nextlink = 'photos/' . $user['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . ($order_field === 'created' ? '?order=created' : '');
}
$tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');