<?php
/**
 * Author model.
 *
 * @package koubel homepage
 * @author Miroslav Kubelik (koubel@volny.cz)
 * @copyright Copyright (c) 2007-2009 Miroslav Kubelik
 * @license http://opensource.org/licenses/gpl-license.php GNU GPL
 */

/**
 * Author model class
 *
 * @package koubel homepage
 * @author Miroslav Kubelik (koubel@volny.cz)
 * @copyright Copyright (c) 2007-2009 Miroslav Kubelik
 * @license http://opensource.org/licenses/gpl-license.php GNU GPL
 */
class Author extends Model
{
    private $_id;

    private $_username;

    private $_email;

    protected function _setDefaultDao()
    {
        $this->setDao(new Dao_Author());
    }

    public function getAll($pageNo=null,$perPageItems=null)
    {
        $rows=$this->getDao()->fetchAllItems($pageNo,$perPageItems);
        return $this->_getSet($rows);
    }

    public function getId()
    {
        return $this->_id;
    }

    public function getUsername()
    {
        return $this->_username;
    }

    public function getEmail()
    {
        return $this->_email;
    }

    public function setByArticle(Article $article)
    {
        $currentArticle=$article->getDaoRow();
        $authorRow=$currentArticle->findParentRow("Dao_Author");
        $this->_setFromDaoRow($authorRow->toArray());
    }

    protected function _setPropFromArray(&$arr)
    {
        foreach($arr as $key=>$val) {
            $this->{"_".$key}=$val;
        }
    }

    protected function _inflectDaoRowIndexes(&$arr)
    {
    }

}
