Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mage_Poll - DOC block update #707

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/code/core/Mage/Poll/Block/ActivePoll.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ public function getPollData($pollId)
// correct rounded percents to be always equal 100
$percentsSorted = array();
$answersArr = array();
/**
* @var int $key
* @var Mage_Poll_Model_Poll_Answer $answer
*/
foreach ($pollAnswers as $key => $answer) {
$percentsSorted[$key] = $answer->getPercent();
$answersArr[$key] = $answer;
Expand Down Expand Up @@ -204,7 +208,7 @@ public function setPollTemplate($template, $type)
*/
protected function _toHtml()
{
/** @var $coreSessionModel Mage_Core_Model_Session */
/** @var Mage_Core_Model_Session $coreSessionModel */
$coreSessionModel = Mage::getSingleton('core/session');
$justVotedPollId = $coreSessionModel->getJustVotedPoll();
if ($justVotedPollId && !$this->_pollModel->isVoted($justVotedPollId)) {
Expand Down
67 changes: 50 additions & 17 deletions app/code/core/Mage/Poll/Model/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@
*
* @method Mage_Poll_Model_Resource_Poll _getResource()
* @method Mage_Poll_Model_Resource_Poll getResource()
* @method string getPollTitle()
* @method Mage_Poll_Model_Poll setPollTitle(string $value)
* @method Mage_Poll_Model_Poll setVotesCount(int $value)
* @method int getStoreId()
* @method Mage_Poll_Model_Poll setStoreId(int $value)
* @method string getDatePosted()
* @method Mage_Poll_Model_Poll setDatePosted(string $value)
* @method string getDateClosed()
* @method Mage_Poll_Model_Poll setDateClosed(string $value)
* @method int getActive()
* @method Mage_Poll_Model_Poll setActive(int $value)
* @method int getClosed()
* @method Mage_Poll_Model_Poll setClosed(int $value)
* @method $this setActive(int $value)
* @method int getAnswersDisplay()
* @method Mage_Poll_Model_Poll setAnswersDisplay(int $value)
* @method $this setAnswersDisplay(int $value)
* @method int getClosed()
* @method $this setClosed(int $value)
* @method string getDateClosed()
* @method $this setDateClosed(string $value)
* @method string getDatePosted()
* @method $this setDatePosted(string $value)
* @method array getExcludeFilter()
* @method $this setExcludeFilter(array $value)
* @method string getPollTitle()
* @method $this setPollTitle(string $value)
* @method int getStoreId()
* @method $this setStoreId(int $value)
* @method $this setStoreIds(array $value)
* @method int getStoreFilter()
* @method $this setStoreFilter(int $value)
* @method $this setVotesCount(int $value)
*
* @category Mage
* @package Mage_Poll
Expand All @@ -55,6 +60,10 @@ class Mage_Poll_Model_Poll extends Mage_Core_Model_Abstract
const XML_PATH_POLL_CHECK_BY_IP = 'web/polls/poll_check_by_ip';

protected $_pollCookieDefaultName = 'poll';

/**
* @var Mage_Poll_Model_Poll_Answer[]
*/
protected $_answersCollection = array();
protected $_storeCollection = array();

Expand Down Expand Up @@ -124,7 +133,7 @@ public function isValidationByIp()
* Declare poll as voted
*
* @param int $pollId
* @return Mage_Poll_Model_Poll
* @return $this
*/
public function setVoted($pollId=null)
{
Expand Down Expand Up @@ -180,7 +189,9 @@ public function getAllIds()
/**
* Add vote to poll
*
* @return unknown
* @param Mage_Poll_Model_Poll_Vote $vote
* @return $this
* @throws Exception
*/
public function addVote(Mage_Poll_Model_Poll_Vote $vote)
{
Expand All @@ -196,7 +207,7 @@ public function addVote(Mage_Poll_Model_Poll_Vote $vote)
* Check answer existing for poll
*
* @param mixed $answer
* @return boll
* @return bool
*/
public function hasAnswer($answer)
{
Expand All @@ -214,13 +225,18 @@ public function hasAnswer($answer)
return false;
}

/**
* @return $this
*/
public function resetVotesCount()
{
$this->_getResource()->resetVotesCount($this);
return $this;
}


/**
* @return array
*/
public function getVotedPollsIds()
{
$idsArray = array();
Expand All @@ -243,17 +259,28 @@ public function getVotedPollsIds()
return $idsArray;
}

/**
* @param Mage_Poll_Model_Poll_Answer $object
* @return $this
*/
public function addAnswer($object)
{
$this->_answersCollection[] = $object;
return $this;
}

/**
* @return Mage_Poll_Model_Poll_Answer[]
*/
public function getAnswers()
{
return $this->_answersCollection;
}

/**
* @param int $storeId
* @return $this
*/
public function addStoreId($storeId)
{
$ids = $this->getStoreIds();
Expand All @@ -264,6 +291,9 @@ public function addStoreId($storeId)
return $this;
}

/**
* @return array
*/
public function getStoreIds()
{
$ids = $this->_getData('store_ids');
Expand All @@ -279,6 +309,9 @@ public function loadStoreIds()
$this->_getResource()->loadStoreIds($this);
}

/**
* @return int
*/
public function getVotesCount()
{
return $this->_getData('votes_count');
Expand Down
27 changes: 21 additions & 6 deletions app/code/core/Mage/Poll/Model/Poll/Answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@
*
* @method Mage_Poll_Model_Resource_Poll_Answer _getResource()
* @method Mage_Poll_Model_Resource_Poll_Answer getResource()
* @method int getPollId()
* @method Mage_Poll_Model_Poll_Answer setPollId(int $value)
* @method int getAnswerOrder()
* @method $this setAnswerOrder(int $value)
* @method string getAnswerTitle()
* @method Mage_Poll_Model_Poll_Answer setAnswerTitle(string $value)
* @method $this setAnswerTitle(string $value)
* @method float getPercent()
* @method $this setPercent(float $round)
* @method int getPollId()
* @method $this setPollId(int $value)
* @method int getVotesCount()
* @method Mage_Poll_Model_Poll_Answer setVotesCount(int $value)
* @method int getAnswerOrder()
* @method Mage_Poll_Model_Poll_Answer setAnswerOrder(int $value)
* @method $this setVotesCount(int $value)
*
* @category Mage
* @package Mage_Poll
Expand All @@ -50,6 +52,10 @@ protected function _construct()
$this->_init('poll/poll_answer');
}

/**
* @param Mage_Poll_Model_Poll $poll
* @return $this
*/
public function countPercent($poll)
{
$this->setPercent(
Expand All @@ -58,18 +64,27 @@ public function countPercent($poll)
return $this;
}

/**
* @return void
*/
protected function _afterSave()
{
Mage::getModel('poll/poll')
->setId($this->getPollId())
->resetVotesCount();
}

/**
* @return void
*/
protected function _beforeDelete()
{
$this->setPollId($this->load($this->getId())->getPollId());
}

/**
* @return void
*/
protected function _afterDelete()
{
Mage::getModel('poll/poll')
Expand Down
6 changes: 3 additions & 3 deletions app/code/core/Mage/Poll/Model/Resource/Poll.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected function _initUniqueFields()
* Get select object for not closed poll ids
*
* @param Mage_Poll_Model_Poll $object
* @return
* @return Varien_Db_Select
*/
protected function _getSelectIds($object)
{
Expand Down Expand Up @@ -134,7 +134,7 @@ public function checkAnswerId($poll, $answerId)
* If poll id is not empty, it will look only for records with specified value
*
* @param string $ipAddress
* @param int $pollId
* @param int|false $pollId
* @return array
*/
public function getVotedPollIdsByIp($ipAddress, $pollId = false)
Expand Down Expand Up @@ -198,7 +198,7 @@ public function loadStoreIds(Mage_Poll_Model_Poll $object)
* Delete current poll from the table poll_store and then
* insert to update "poll to store" relations
*
* @param Mage_Core_Model_Abstract $object
* @param Mage_Core_Model_Abstract|Mage_Poll_Model_Poll $object
*/
public function _afterSave(Mage_Core_Model_Abstract $object)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* @category Mage
* @package Mage_Poll
* @author Magento Core Team <core@magentocommerce.com>
*
* @method Mage_Poll_Model_Poll_Answer[] getItems()
*/
class Mage_Poll_Model_Resource_Poll_Answer_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
Expand Down Expand Up @@ -64,7 +66,7 @@ public function addPollFilter($pollId)
public function countPercent($pollObject)
{
if (!$pollObject) {
return;
return $this;
sreichel marked this conversation as resolved.
Show resolved Hide resolved
} else {
foreach ($this->getItems() as $answer) {
$answer->countPercent($pollObject);
Expand Down
3 changes: 3 additions & 0 deletions app/code/core/Mage/Poll/Model/Resource/Poll/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
* @category Mage
* @package Mage_Poll
* @author Magento Core Team <core@magentocommerce.com>
*
* @method int getId()
* @method $this setSelectStores(array $value)
*/
class Mage_Poll_Model_Resource_Poll_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
{
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Poll/Model/Resource/Poll/Vote.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function _construct()
/**
* Perform actions after object save
*
* @param Varien_Object $object
* @param Mage_Core_Model_Abstract|Mage_Poll_Model_Poll_Vote $object
* @return $this
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Poll/controllers/VoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function addAction()
$pollId = intval($this->getRequest()->getParam('poll_id'));
$answerId = intval($this->getRequest()->getParam('vote'));

/** @var $poll Mage_Poll_Model_Poll */
/** @var Mage_Poll_Model_Poll $poll */
$poll = Mage::getModel('poll/poll')->load($pollId);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/


/* @var $installer Mage_Core_Model_Resource_Setup */
/* @var Mage_Core_Model_Resource_Setup $installer */

$installer = $this;

Expand Down
2 changes: 1 addition & 1 deletion app/code/core/Mage/Poll/sql/poll_setup/install-1.6.0.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/


/* @var $installer Mage_Core_Model_Resource_Setup */
/* @var Mage_Core_Model_Resource_Setup $installer */

$installer = $this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

$installer = $this;
/* @var $installer Mage_Core_Model_Resource_Setup */
/* @var Mage_Core_Model_Resource_Setup $installer */

$installer->startSetup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
*/

$installer = $this;
/* @var $installer Mage_Core_Model_Resource_Setup */
/* @var Mage_Core_Model_Resource_Setup $installer */

$installer->startSetup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/* @var $installer Mage_Core_Model_Resource_Setup */
/* @var Mage_Core_Model_Resource_Setup $installer */
$installer = $this;
$installer->startSetup();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/

/* @var $installer Mage_Core_Model_Resource_Setup */
/* @var Mage_Core_Model_Resource_Setup $installer */
$installer = $this;
$installer->startSetup();

Expand Down