getAlbums.php 602 B

1234567891011121314151617181920
  1. <?php
  2. require_once('../../../lib/base.php');
  3. OC_JSON::checkLoggedIn();
  4. OC_JSON::checkAppEnabled('gallery');
  5. $a = array();
  6. $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ?');
  7. $result = $stmt->execute(array(OC_User::getUser()));
  8. while ($r = $result->fetchRow()) {
  9. $album_name = $r['album_name'];
  10. $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_photos WHERE `album_id` = ?');
  11. $tmp_res = $stmt->execute(array($r['album_id']));
  12. $a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10));
  13. }
  14. OC_JSON::success(array('albums'=>$a));
  15. ?>