From fb5c43b2df8a190fecfe4bf04bcd64aa1bad9c2d Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 6 Aug 2007 01:57:29 +0000 Subject: proof of concept, nothing one should actually use --- stats.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'stats.php') diff --git a/stats.php b/stats.php index 63fa4f3a..2b99df95 100644 --- a/stats.php +++ b/stats.php @@ -44,6 +44,47 @@ switch ($_REQUEST['action']) { require_once Config::get('prefix') . '/templates/show_user_stats.inc.php'; + break; + //FIXME:: The logic in here should be moved to our metadata class + case 'recommend_similar': + // For now this is just MyStrands so verify they've filled out stuff + if (!$GLOBALS['user']->has_access('25') || !$GLOBALS['user']->prefs['mystrands_pass'] || !$GLOBALS['user']->prefs['mystrands_user']) { + access_denied(); + exit; + } + + // We're good attempt to dial up MyStrands + OpenStrands::set_auth_token(Config::get('mystrands_developer_key')); + $openstrands = new OpenStrands($GLOBALS['user']->prefs['mystrands_user'],$GLOBALS['user']->prefs['mystrands_pass']); + + if (!$openstrands) { + debug_event('openstrands','Unable to authenticate MyStrands user, or authtoken invalid','3'); + Error::add('general','Unable to authenticate MyStrands user, or authtoken invalid'); + } + + // Do our recommendation + switch ($_REQUEST['type']) { + case 'artist': + $artist = new Artist($_REQUEST['id']); + $seed = array('name'=>array($artist->name)); + $results = $openstrands->recommend_artists($seed); + break; + } // end switch + + // Run through what we've found and build out the data + foreach ($results as $result) { + + switch ($_REQUEST['type']) { + case 'artist': + $data['name'] = $result['ArtistName']; + $data['f_name_link'] = "" . $data['name'] . ""; + $object_ids[] = Artist::construct_from_array($data); + break; + } + } // end foreach + + require_once Config::get('prefix') . '/templates/show_artists.inc.php'; + break; /* Show their stats */ default: -- cgit