summaryrefslogtreecommitdiffstats
path: root/apps/gallery/ajax/getAlbums.php
blob: 38bea74636fb0e0604e2ac624fbf61324d579ffa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('gallery');

$a = array();
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ?');
$result = $stmt->execute(array(OC_User::getUser()));

while ($r = $result->fetchRow()) {
  $album_name = $r['album_name'];
  $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE `album_id` = ?');
  $tmp_res = $stmt->execute(array($r['album_id']));
  $a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10));
}

OC_JSON::success(array('albums'=>$a));

?>