<?php

    lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" );

    /**
     * Poll Vote
     */
    class Poll extends DbObject
	{

    	var $_id;
        var $_text;
        var $_blogId;
        var $_choices;

        function Poll( $text, $blogId, $choices = array(), $id = 0 )
        {   
            $this->_text = $text;
            $this->_blogId = $blogId;
        	$this->_id = $id;
        	$this->_choices = $choices;
        	$this->_pk = 'id';
        	$this->_fields = Array(
        	   "id" => "getId",
        	   "text" => "getText",
        	   "blog_id" => "getBlogId",
        	   "choices" => "getSerializedChoices"
        	);
        }
        
        /**
         * Set methods
         */
        function setId( $id )
        {
            $this->_id = $id;
        }
        function setText( $text )
        {
            $this->_text = $text;
        }
        function setBlogId( $blogId )
        {
            $this->_blogId = $blogId;
        }
        function setChoices( $choices )
        {
            $this->_choices = $choices;
        }
        /**
         * Get methods
         */
        function getId()
        {
            return $this->_id;
        }
        function getBlogId()
        {
            return $this->_blogId;
        }
        function getText()
        {
            return $this->_text;
        }
        function getChoices()
        {
            return $this->_choices;
        }
        function getSerializedChoices()
        {
            return serialize( $this->_choices );
        }
        function getChoicesVotesCount()
        {
            lt_include( PLOG_CLASS_PATH."plugins/crystalpoll/class/dao/polls.class.php" );
            $polls = new Polls();
            return $polls->getChoicesVotesCount($this->_id);
        }
    }
?>