OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); $offset = isset($_GET['offset']) ? $_GET['offset'] : 0; $aid = isset($_GET['aid']) ? $_GET['aid'] : null; $active_addressbooks = array(); if (is_null($aid)) { // Called initially to get the active addressbooks. $active_addressbooks = OCA\Contacts\Addressbook::active(OCP\USER::getUser()); } else { // called each time more contacts has to be shown. $active_addressbooks = array(OCA\Contacts\Addressbook::find($aid)); } $lastModified = OCA\Contacts\App::lastModified(); if (!is_null($lastModified)) { OCP\Response::enableCaching(); OCP\Response::setLastModifiedHeader($lastModified); OCP\Response::setETagHeader(md5($lastModified->format('U'))); } session_write_close(); // create the addressbook associate array $contacts_addressbook = array(); $ids = array(); foreach ($active_addressbooks as $addressbook) { $ids[] = $addressbook['id']; /*if(!isset($contacts_addressbook[$addressbook['id']])) { $contacts_addressbook[$addressbook['id']] = array('contacts' => array('type' => 'book',)); $contacts_addressbook[$addressbook['id']]['displayname'] = $addressbook['displayname']; $contacts_addressbook[$addressbook['id']]['description'] = $addressbook['description'];
public static function setLastModifiedHeader($contact) { $rev = $contact->getAsString('REV'); if ($rev) { $rev = DateTime::createFromFormat(DateTime::W3C, $rev); OCP\Response::setLastModifiedHeader($rev); } }
$song['album'] = OC_MEDIA_COLLECTION::getAlbumName($song['song_album']); OCP\JSON::encodedPrint($song); } } break; case 'play': @ob_end_clean(); $ftype = OC_Filesystem::getMimeType($arguments['path']); if (substr($ftype, 0, 5) != 'audio' and $ftype != 'application/ogg') { echo 'Not an audio file'; exit; } $songId = OC_MEDIA_COLLECTION::getSongByPath($arguments['path']); OC_MEDIA_COLLECTION::registerPlay($songId); header('Content-Type:' . $ftype); OCP\Response::enableCaching(3600 * 24); // 24 hour header('Accept-Ranges: bytes'); header('Content-Length: ' . OC_Filesystem::filesize($arguments['path'])); $mtime = OC_Filesystem::filemtime($arguments['path']); OCP\Response::setLastModifiedHeader($mtime); OC_Filesystem::readfile($arguments['path']); exit; case 'find_music': $music = OC_FileCache::searchByMime('audio'); $ogg = OC_FileCache::searchByMime('application', 'ogg'); $music = array_merge($music, $ogg); OCP\JSON::encodedPrint($music); exit; } }