require_once('include/threads.php');
require_once('include/Probe.php');
+use \Friendica\Core\Config;
+
function photos_init(App $a) {
if ($a->argc > 1)
$prevlink = '';
$nextlink = '';
- if ($_GET['order'] === 'posted')
- $order = 'ASC';
- else
- $order = 'DESC';
-
/// @todo This query is totally bad, the whole functionality has to be changed
- $prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
- $sql_extra ORDER BY `created` $order ",
- dbesc($ph[0]['album']),
- intval($owner_uid)
- );
+ // The query leads to a really intense used index.
+ // By now we hide it if someone wants to.
+ if (!Config::get('system', 'no_count', false)) {
+ if ($_GET['order'] === 'posted')
+ $order = 'ASC';
+ else
+ $order = 'DESC';
- if (count($prvnxt)) {
- for($z = 0; $z < count($prvnxt); $z++) {
- if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
- $prv = $z - 1;
- $nxt = $z + 1;
- if ($prv < 0)
- $prv = count($prvnxt) - 1;
- if ($nxt >= count($prvnxt))
- $nxt = 0;
- break;
- }
- }
- $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
- $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
- $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
- }
+ $prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
+ $sql_extra ORDER BY `created` $order ",
+ dbesc($ph[0]['album']),
+ intval($owner_uid)
+ );
+ if (count($prvnxt)) {
+ for($z = 0; $z < count($prvnxt); $z++) {
+ if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
+ $prv = $z - 1;
+ $nxt = $z + 1;
+ if ($prv < 0)
+ $prv = count($prvnxt) - 1;
+ if ($nxt >= count($prvnxt))
+ $nxt = 0;
+ break;
+ }
+ }
+ $edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
+ $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
+ $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
+ }
+ }
if (count($ph) == 1)
$hires = $lores = $ph[0];