Exemple #1
0
 /**
  * Calls the cleanup method of the scanner
  */
 public static function run()
 {
     $app = new Music();
     $container = $app->getContainer();
     // remove orphaned entities
     $container->query('Helper')->cleanUp();
     // find covers - TODO performance stuff - maybe just call this once in an hour
     $container->query('AlbumBusinessLayer')->findCovers();
     // remove expired sessions
     $container->query('AmpacheSessionMapper')->cleanUp();
 }
Exemple #2
0
 /**
  * Invoke auto update of music database after item gets shared
  * @param array $params contains the params of the added share
  */
 public static function itemShared($params)
 {
     $app = new Music();
     $container = $app->getContainer();
     if ($params['itemType'] === 'folder') {
         $backend = new \OC_Share_Backend_Folder();
         foreach ($backend->getChildren($params['itemSource']) as $child) {
             $container->query('Scanner')->updateById((int) $child['source'], $params['shareWith']);
         }
     } else {
         if ($params['itemType'] === 'file') {
             $container->query('Scanner')->updateById((int) $params['itemSource'], $params['shareWith']);
         }
     }
 }
Exemple #3
0
 public function search($query)
 {
     $app = new Music();
     $c = $app->getContainer();
     $artistMapper = $c->query('ArtistMapper');
     $albumMapper = $c->query('AlbumMapper');
     $trackMapper = $c->query('TrackMapper');
     $urlGenerator = $c->getServer()->getURLGenerator();
     $userId = $c->query('UserId');
     $l10n = $c->query('L10N');
     $pattern = $query;
     $results = array();
     $artists = $artistMapper->findAllByName($pattern, $userId, true);
     $container = '';
     $text = '';
     foreach ($artists as $artist) {
         $name = $artist->name;
         $link = $urlGenerator->linkToRoute('music.page.index') . '#/artist/' . $artist->id;
         $type = (string) $l10n->t('Artists');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     $albums = $albumMapper->findAllByName($pattern, $userId, true);
     foreach ($albums as $album) {
         $name = $album->name;
         $link = $urlGenerator->linkToRoute('music.page.index') . '#/album/' . $album->id;
         $type = (string) $l10n->t('Albums');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     $tracks = $trackMapper->findAllByName($pattern, $userId, true);
     foreach ($tracks as $track) {
         $name = $track->title;
         $link = $urlGenerator->linkToRoute('music.page.index') . '#/track/' . $track->id;
         $type = (string) $l10n->t('Tracks');
         $results[] = new \OC_Search_Result($name, $text, $link, $type, $container);
     }
     return $results;
 }
Exemple #4
0
 /**
  * Invoke auto update of music database after file update or file creation
  * @param array $params contains a key value pair for the path of the file/dir
  */
 public static function updated($params)
 {
     $app = new Music();
     $container = $app->getContainer();
     $container->query('Scanner')->updateByPath($params['path']);
 }
Exemple #5
0
<?php

/**
 * ownCloud - Music app
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Morris Jobke <*****@*****.**>
 * @copyright Morris Jobke 2013, 2014
 */
namespace OCA\Music;

use OCA\Music\App\Music;
$app = new Music();
$c = $app->getContainer();
$c->query('API')->addScript('public/settings-user');
$c->query('API')->addStyle('settings-user');
$tmpl = new \OCP\Template($c->query('AppName'), 'settings-user');
$tmpl->assign('path', $c->query('Config')->getUserValue($c->query('UserId'), $c->query('AppName'), 'path'));
$tmpl->assign('ampacheKeys', $c->query('AmpacheUserMapper')->getAll($c->query('UserId')));
$tmpl->assign('URLGenerator', $c->query('URLGenerator'));
return $tmpl->fetchPage();