Files
Phraseanet/lib/classes/Feed/TokenAggregate.class.php
Romain Neutron 4c5b7eb658 V 3.5 RC 1
2011-12-05 00:23:28 +01:00

64 lines
1.2 KiB
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package Feeds
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class Feed_TokenAggregate extends Feed_Token
{
/**
*
* @param appbox $appbox
* @param string $token
* @return Feed_TokenAggregate
*/
public function __construct(appbox &$appbox, $token)
{
$sql = 'SELECT usr_id FROM feed_tokens
WHERE aggregated = "1" AND token = :token';
$params = array(
':token' => $token
);
$stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$row)
throw new Exception_FeedNotFound($token);
$this->usr_id = $row['usr_id'];
$this->appbox = $appbox;
return $this;
}
/**
*
* @return Feed_Aggregate
*/
public function get_feed()
{
if (!$this->feed)
$this->feed = Feed_Aggregate::load_with_user($this->appbox, $this->get_user());
return $this->feed;
}
}