public function indexAction() { $this->acl->checkPermission('is logged in'); $user = $this->auth->getLoggedInUser(); $this->view->user = $user; // Process external authentication providers. $external_providers = UserExternal::getExternalProviders(); if (count($user->external_accounts) > 0) { foreach ($user->external_accounts as $ext) { $external_providers[$ext->provider]['existing'] = $ext; } } $this->view->external_providers = $external_providers; // Create song lists. $song_lists = array('requested' => array('name' => 'Songs I Requested', 'icon' => 'icon-question-sign', 'items' => array()), 'liked' => array('name' => 'Songs I Liked', 'icon' => 'icon-thumbs-up', 'items' => array()), 'disliked' => array('name' => 'Songs I Disliked', 'icon' => 'icon-thumbs-down', 'items' => array())); $liked_raw = $this->em->createQuery('SELECT sv, s, st FROM Entity\\SongVote sv JOIN sv.song s JOIN sv.station st WHERE sv.user_id = :user_id ORDER BY sv.timestamp DESC')->setParameter('user_id', $user->id)->getArrayResult(); foreach ($liked_raw as $row) { $item = array('timestamp' => $row['timestamp'], 'station' => $row['station'], 'song' => $row['song']); if ((int) $row['vote'] > 0) { $song_lists['liked']['items'][] = $item; } else { $song_lists['disliked']['items'][] = $item; } } $requested_raw = $this->em->createQuery('SELECT sr, s, tr, st FROM Entity\\StationRequest sr JOIN sr.station st JOIN sr.track tr JOIN tr.song s WHERE sr.user_id = :user_id ORDER BY sr.timestamp DESC')->setParameter('user_id', $user->id)->getArrayResult(); foreach ($requested_raw as $row) { $item = array('timestamp' => $row['timestamp'], 'station' => $row['station'], 'song' => $row['track']['song']); $song_lists['requested']['items'][] = $item; } $this->view->song_lists = $song_lists; }
public function linkAction() { $this->acl->checkPermission('is logged in'); $this->doNotRender(); // Link external account. $user = $this->auth->getLoggedInUser(); $provider_name = $this->getParam('provider'); $ha_config = $this->_getHybridConfig(); $hybridauth = new \Hybrid_Auth($ha_config); // try to authenticate with the selected provider $adapter = $hybridauth->authenticate($provider_name); if ($hybridauth->isConnectedWith($provider_name)) { $user_profile = $adapter->getUserProfile(); UserExternal::processExternal($provider_name, $user_profile, $user); $this->alert('<b>Account successfully linked!</b>', 'green'); $this->redirectToRoute(array('module' => 'default', 'controller' => 'profile')); return; } }