Example #1
13
<?php

include "inc/includes.php";
require_once "inc/Restaurant.php";
require_once "inc/Cuisine.php";
require_once "inc/Filter.php";
global $USER_LOGGED_IN;
global $USERID;
// Generate the default recommendations if user is logged in.
if ($USER_LOGGED_IN) {
    $recommendation = new Recommendation($USERID);
    $filter = new Filter();
    $filter->setCuisine(7);
    $result = $recommendation->getFilteredWithCategory(2, $filter);
    while ($reco = mysql_fetch_array($result)) {
        $restaurant = new Restaurant($reco['resId']);
        echo $restaurant->getName() . "," . $restaurant->getAddress();
        $cuisines = $restaurant->getCategories();
        foreach ($cuisines as $cuisine) {
            echo $cuisine->getName();
        }
    }
}
?>
<html>
  <body>
  <?php 
getFacebookWidget();
?>
  </body>
</html>
 public function run()
 {
     DB::table('menus')->delete();
     DB::table('dish_menu')->delete();
     DB::table('recommendations')->delete();
     $menu = new Menu();
     $menu->menu_date = "2014-03-30";
     $menu->save();
     foreach (Dish::all() as $dish) {
         $menu->dishes()->save($dish);
     }
     $menu = new Menu();
     $menu->menu_date = "2014-04-23";
     $menu->save();
     foreach (Dish::all() as $dish) {
         $menu->dishes()->save($dish);
     }
     $recommendation = new Recommendation();
     $recommendation->menu_id = 1;
     $recommendation->recommendation = "Today, we has abcxyz for menu 1";
     $recommendation->save();
     $recommendation = new Recommendation();
     $recommendation->menu_id = 2;
     $recommendation->recommendation = "Today, we has abcxyz for menu 2";
     $recommendation->save();
 }
 public function doAdd($user_id)
 {
     if (!me()->hasPermissionTo('add', 'Recommendation')) {
         err('You don\'t have permission to leave a recommendation for that user.');
         return Redirect::to(URL::previous());
     }
     $recommendation = new Recommendation();
     return $recommendation->validateAndUpdateFromArray(Input::all());
 }
 public function postCreateMenu()
 {
     /* validate input */
     $validator = Validator::make(Input::all(), array("menu_date" => "required|date_format:Y-m-d", "dishes" => "required", "recommendation" => "required"));
     /* if validated */
     if ($validator->passes()) {
         /* get input */
         $menu = new Menu();
         $menu->menu_date = Input::get("menu_date");
         $menu->save();
         $recommendation = new Recommendation();
         $recommendation->menu_id = $menu->id;
         $recommendation->recommendation = Input::get("recommendation");
         $recommendation->save();
         foreach (Input::get('dishes') as $dishId) {
             $menu->dishes()->save(Dish::find((int) $dishId));
         }
         return Redirect::to('admin/menu/create_menu')->with('message', 'Menu added!');
     } else {
         return Redirect::to('admin/menu/create_menu')->withErrors($validator);
     }
     // end validation
 }
Example #5
0
 /**
  * get_past_events
  * Returns a list of past events
  * @param Artist $artist
  * @return SimpleXMLElement|boolean
  */
 public static function get_past_events(Artist $artist)
 {
     if (isset($artist->mbid)) {
         $query = 'mbid=' . rawurlencode($artist->mbid);
     } else {
         $query = 'artist=' . rawurlencode($artist->name);
     }
     $limit = AmpConfig::get('concerts_limit_past');
     if ($limit) {
         $query .= '&limit=' . $limit;
     }
     $xml = Recommendation::get_lastfm_results('artist.getpastevents', $query);
     if ($xml->events) {
         return $xml->events;
     }
     return false;
 }
Example #6
0
 /**
  * gather_lastfm
  * This returns the art from lastfm. It doesn't currently require an
  * account but may in the future.
  * @param int $limit
  * @param array $data
  * @return array
  */
 public function gather_lastfm($limit = 5, $data = array())
 {
     if (!$limit) {
         $limit = 5;
     }
     $images = array();
     if ($this->type != 'album' || empty($data['artist']) || empty($data['album'])) {
         return $images;
     }
     try {
         $xmldata = Recommendation::album_search($data['artist'], $data['album']);
         if (!count($xmldata)) {
             return array();
         }
         $xalbum = $xmldata->album;
         if (!$xalbum) {
             return array();
         }
         $coverart = (array) $xalbum->image;
         if (!$coverart) {
             return array();
         }
         ksort($coverart);
         foreach ($coverart as $url) {
             // We need to check the URL for the /noimage/ stuff
             if (is_array($url) || strpos($url, '/noimage/') !== false) {
                 debug_event('LastFM', 'Detected as noimage, skipped ' . $url, 3);
                 continue;
             }
             // HACK: we shouldn't rely on the extension to determine file type
             $results = pathinfo($url);
             $mime = 'image/' . $results['extension'];
             $images[] = array('url' => $url, 'mime' => $mime, 'title' => 'LastFM');
             if ($limit && count($images) >= $limit) {
                 return $images;
             }
         }
         // end foreach
     } catch (Exception $e) {
         debug_event('art', 'LastFM error: ' . $e->getMessage(), 5);
     }
     return $images;
 }
Example #7
0
 /**
  * getSimilarSongs
  * Returns a random collection of songs from the given artist and similar artists, using data from last.fm. Typically used for artist radio features.
  * Takes song/album/artist id in parameter with optional similar songs count.
  */
 public static function getsimilarsongs($input)
 {
     $id = self::check_parameter($input, 'id');
     $count = $input['count'] ?: 50;
     $songs = null;
     if (Subsonic_XML_Data::isArtist($id)) {
         // TODO: support similar songs for artists
     } elseif (Subsonic_XML_Data::isAlbum($id)) {
         // TODO: support similar songs for albums
     } elseif (Subsonic_XML_Data::isSong($id)) {
         if (AmpConfig::get('show_similar')) {
             $songs = Recommendation::get_songs_like(Subsonic_XML_Data::getAmpacheId($id));
         }
     }
     if ($songs === null) {
         $r = Subsonic_XML_Data::createError(Subsonic_XML_Data::SSERROR_DATA_NOTFOUND);
     } else {
         $r = Subsonic_XML_Data::createSuccessResponse();
         Subsonic_XML_Data::addSimilarSongs($r, $songs);
     }
     self::apiOutput($input, $r);
 }
 public function index()
 {
     $recommendations = Recommendation::All();
     return Response::json(array('recommendations' => $recommendations->toArray()));
 }
Example #9
0
                     $object_ids[] = $similar['id'];
                 } else {
                     $missing_objects[] = $similar;
                 }
             }
         }
         ob_start();
         require_once AmpConfig::get('prefix') . UI::find_template('show_recommended_artists.inc.php');
         $results['similar_artist'] = ob_get_clean();
     }
     break;
 case 'similar_now_playing':
     $media_id = $_REQUEST['media_id'];
     if (AmpConfig::get('show_similar') && isset($media_id) && isset($_REQUEST['media_artist'])) {
         $artists = Recommendation::get_artists_like($_REQUEST['media_artist'], 3, false);
         $songs = Recommendation::get_songs_like($media_id, 3);
         ob_start();
         require_once AmpConfig::get('prefix') . UI::find_template('show_now_playing_similar.inc.php');
         $results['similar_items_' . $media_id] = ob_get_clean();
     }
     break;
 case 'concerts':
     if (AmpConfig::get('show_concerts') && isset($_REQUEST['artist'])) {
         $artist = new Artist($_REQUEST['artist']);
         $artist->format();
         if ($artist->id) {
             $up_concerts = Artist_Event::get_upcoming_events($artist);
             $past_concerts = Artist_Event::get_past_events($artist);
             $coming_concerts = array();
             $concerts = array();
             if ($up_concerts) {
Example #10
0
 /**
  * insert_local_song
  *
  * Insert a song that isn't already in the database.
  */
 private function insert_local_song($file, $options = array())
 {
     $vainfo = new vainfo($file, $this->get_gather_types('music'), '', '', '', $this->sort_pattern, $this->rename_pattern);
     $vainfo->get_info();
     $key = vainfo::get_tag_type($vainfo->tags);
     $results = vainfo::clean_tag_info($vainfo->tags, $key, $file);
     $results['catalog'] = $this->id;
     if (isset($options['user_upload'])) {
         $results['user_upload'] = $options['user_upload'];
     }
     if (isset($options['license'])) {
         $results['license'] = $options['license'];
     }
     if (isset($options['artist_id'])) {
         $results['artist_id'] = $options['artist_id'];
         $results['albumartist_id'] = $options['artist_id'];
     }
     if (isset($options['album_id'])) {
         $results['album_id'] = $options['album_id'];
     }
     $id = Song::insert($results);
     // If song rating tag exists and is well formed (array user=>rating), add it
     if ($id && array_key_exists('rating', $results) && is_array($results['rating'])) {
         // For each user's ratings, call the function
         foreach ($results['rating'] as $user => $rating) {
             debug_event('Rating', "Setting rating for Song {$id} to {$rating} for user {$user}", 5);
             $o_rating = new Rating($id, 'song');
             $o_rating->set_rating($rating, $user);
         }
     }
     // Extended metadata loading is not deferred, retrieve it now
     if ($id && !AmpConfig::get('deferred_ext_metadata')) {
         $song = new Song($id);
         Recommendation::get_artist_info($song->artist);
     }
     if (Song::isCustomMetadataEnabled()) {
         if (!$song) {
             $song = new Song($id);
         }
         $results = array_diff_key($results, array_flip($song->getDisabledMetadataFields()));
         self::add_metadata($song, $results);
     }
     $this->added_songs_to_gather[] = $id;
     $this->_filecache[strtolower($file)] = $id;
     return $id;
 }
Example #11
0
 public function deleteActivePrinciples()
 {
     $recommendation = new Recommendation();
     if (!$this->checkUser(Input::get("currentPassword"))) {
         return Response::json(array("success" => false, "info" => "ContraseƱa introducida incorrecta."));
     }
     DB::table($recommendation->getTableName())->update(array("active_principle_id" => NULL));
     DB::table("active_principles")->delete();
     return Response::json(array("success" => true, "info" => "Todos los registros de principios activos han sido eliminados."));
 }
 * the way it works is first the user searches for another user by their username
 * then when they click on a user to send the recommendation to it will show them a form
 * to enter a message and select an album
 */
 
 if (!$_SESSION['user']) {
 	die('You need to login to send recommendations');
 }
 
require_once('../database/config.php');
$conn = Doctrine_Manager :: connection(DSN);
$current_user_id = $_SESSION['user']['user_id'];
		          
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
	//we are posting to the web server, so save the recommendation
	$recommendation = new Recommendation();
	$recommendation['note'] = $_POST['message'];
	$recommendation['from_user_id'] = $_SESSION['user']['user_id'];
	$recommendation['to_user_id'] = $_POST['to_user_id'];
	$recommendation['album_id'] = $_POST['album_id'];
	$recommendation->save();
	$send = true;
}else if (isset($_GET['search_username'])) {
	//Search for all the usernames that match the criteria
	$search = Doctrine::getTable('User')
	               ->getTemplate('Doctrine_Template_Searchable')
	               ->getPlugin();
		
		$results = $search->search($_GET['search_username']);
		foreach($results as $result) {
			$user_ids[] = (int) $result['user_id'];
Example #13
0
 /**
  * insert_local_song
  *
  * Insert a song that isn't already in the database.
  */
 private function insert_local_song($file, $options = array())
 {
     $vainfo = new vainfo($file, $this->get_gather_types('music'), '', '', '', $this->sort_pattern, $this->rename_pattern);
     $vainfo->get_info();
     $key = vainfo::get_tag_type($vainfo->tags);
     $results = vainfo::clean_tag_info($vainfo->tags, $key, $file);
     $results['catalog'] = $this->id;
     if (isset($options['user_upload'])) {
         $results['user_upload'] = $options['user_upload'];
     }
     if (isset($options['license'])) {
         $results['license'] = $options['license'];
     }
     if (isset($options['artist_id'])) {
         $results['artist_id'] = $options['artist_id'];
         $results['albumartist_id'] = $options['artist_id'];
     }
     if (isset($options['album_id'])) {
         $results['album_id'] = $options['album_id'];
     }
     $id = Song::insert($results);
     // Extended metadata loading is not deferred, retrieve it now
     if ($id && !AmpConfig::get('deferred_ext_metadata')) {
         $song = new Song($id);
         Recommendation::get_artist_info($song->artist);
     }
     $this->added_songs_to_gather[] = $id;
     $this->_filecache[strtolower($file)] = $id;
     return $id;
 }
Example #14
0
<?php

namespace tatt;
require_once 'tatt/webcommon.php';

$recommendations = Recommendation::recommend_items(4);

foreach($recommendations as $recommendation) {
    $item = new Item($recommendation);
    $items[] = $item->to_array();
}

$page->assign('items', $items);
$page->assign('page_title', 'Recommendations');
$page->display('items/item_recommendations.tpl');
Example #15
0
<?php

include "inc/includes.php";
require_once "inc/Restaurant.php";
require_once "inc/Cuisine.php";
global $USER_LOGGED_IN;
global $USERID;
// Generate the default recommendations if user is logged in.
if ($USER_LOGGED_IN) {
    $recommendation = new Recommendation($USERID);
    $result = $recommendation->getFilteredNotVisited();
    while ($reco = mysql_fetch_array($result)) {
        $restaurant = new Restaurant($reco['resId']);
        echo $restaurant->getName() . "," . $restaurant->getAddress();
        $cuisines = $restaurant->getCuisines();
        foreach ($cuisines as $cuisine) {
            echo $cuisine->getName();
        }
    }
}
?>
<html>
  <body>
  <?php 
getFacebookWidget();
?>
  </body>
</html>