diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php b/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php deleted file mode 100644 index 0d20da9ff20..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit.php +++ /dev/null @@ -1,69 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Answer_Edit extends Mage_Adminhtml_Block_Widget_Form_Container -{ - public function __construct() - { - parent::__construct(); - - $this->_objectId = 'id'; - $this->_controller = 'poll_answer'; - - if ($this->getRequest()->getParam($this->_objectId)) { - $answerData = Mage::getModel('poll/poll_answer') - ->load($this->getRequest()->getParam($this->_objectId)); - Mage::register('answer_data', $answerData); - } - - $this->_updateButton( - 'back', - 'onclick', - Mage::helper('core/js')->getSetLocationJs( - $this->getUrl( - '*/poll/edit', - ['id' => $answerData->getPollId(), 'tab' => 'answers_section'] - ) - ) - ); - $this->_updateButton('save', 'label', Mage::helper('poll')->__('Save Answer')); - $this->_updateButton('delete', 'label', Mage::helper('poll')->__('Delete Answer')); - } - - /** - * @return string - */ - public function getHeaderText() - { - return Mage::helper('poll')->__( - "Edit Answer '%s'", - $this->escapeHtml(Mage::registry('answer_data')->getAnswerTitle()) - ); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit/Form.php deleted file mode 100644 index 32d8177cc7a..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Answer/Edit/Form.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Answer_Edit_Form extends Mage_Adminhtml_Block_Widget_Form -{ - protected function _prepareForm() - { - $form = new Varien_Data_Form(); - - $fieldset = $form->addFieldset('edit_answer_form', ['legend' => Mage::helper('poll')->__('Edit Poll Answer')]); - - $fieldset->addField('answer_title', 'text', [ - 'name' => 'answer_title', - 'title' => Mage::helper('poll')->__('Answer Title'), - 'label' => Mage::helper('poll')->__('Answer Title'), - 'required' => true, - 'class' => 'required-entry', - ]); - - $fieldset->addField('votes_count', 'text', [ - 'name' => 'votes_count', - 'title' => Mage::helper('poll')->__('Votes Count'), - 'label' => Mage::helper('poll')->__('Votes Count'), - 'class' => 'validate-not-negative-number' - ]); - - $fieldset->addField('poll_id', 'hidden', [ - 'name' => 'poll_id', - 'no_span' => true, - ]); - - $form->setValues(Mage::registry('answer_data')->getData()); - $form->setUseContainer(true); - $form->setId('edit_form'); - $form->setMethod('post'); - $form->setAction($this->getUrl('*/*/save', ['id' => Mage::registry('answer_data')->getAnswerId()])); - $this->setForm($form); - return $this; - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit.php deleted file mode 100644 index d223d469ebd..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Edit extends Mage_Adminhtml_Block_Widget_Form_Container -{ - public function __construct() - { - parent::__construct(); - - $this->_objectId = 'id'; - $this->_controller = 'poll'; - - $this->_updateButton('save', 'label', Mage::helper('poll')->__('Save Poll')); - $this->_updateButton('delete', 'label', Mage::helper('poll')->__('Delete Poll')); - - $this->setValidationUrl($this->getUrl('*/*/validate', ['id' => $this->getRequest()->getParam($this->_objectId)])); - } - - /** - * @return string - */ - public function getHeaderText() - { - if (Mage::registry('poll_data') && Mage::registry('poll_data')->getId()) { - return Mage::helper('poll')->__("Edit Poll '%s'", $this->escapeHtml(Mage::registry('poll_data')->getPollTitle())); - } - return Mage::helper('poll')->__('New Poll'); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Form.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Form.php deleted file mode 100644 index 1e3da49fd5b..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Form.php +++ /dev/null @@ -1,43 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Edit_Form extends Mage_Adminhtml_Block_Widget_Form -{ - protected function _prepareForm() - { - $form = new Varien_Data_Form([ - 'id' => 'edit_form', - 'action' => $this->getUrl('*/*/save', ['id' => $this->getRequest()->getParam('id')]), - 'method' => 'post', - ]); - - $form->setUseContainer(true); - $this->setForm($form); - return parent::_prepareForm(); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers.php deleted file mode 100644 index 7c7b59ff003..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers.php +++ /dev/null @@ -1,31 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Edit_Tab_Answers extends Mage_Adminhtml_Block_Text_List -{ -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Form.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Form.php deleted file mode 100644 index edbe41ff64c..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Form.php +++ /dev/null @@ -1,64 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Edit_Tab_Answers_Form extends Mage_Adminhtml_Block_Widget_Form -{ - protected function _prepareForm() - { - $form = new Varien_Data_Form(); - - $fieldset = $form->addFieldset('add_answer_form', ['legend' => Mage::helper('poll')->__('Add New Answer')]); - - $fieldset->addField('answer_title', 'text', [ - 'name' => 'answer_title', - 'title' => Mage::helper('poll')->__('Answer Title'), - 'label' => Mage::helper('poll')->__('Answer Title'), - 'maxlength' => '255', - 'no_span' => true, - ]); - - $fieldset->addField('poll_id', 'hidden', [ - 'name' => 'poll_id', - 'no_span' => true, - 'value' => $this->getRequest()->getParam('id'), - ]); - - $fieldset->addField('add_button', 'note', [ - 'text' => $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('poll')->__('Add Answer'), - 'onclick' => 'answers.add();', - 'class' => 'add', - ])->toHtml(), - 'no_span' => true, - ]); - - $this->setForm($form); - return $this; - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Grid.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Grid.php deleted file mode 100644 index edce03c4834..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/Grid.php +++ /dev/null @@ -1,99 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Edit_Tab_Answers_Grid extends Mage_Adminhtml_Block_Widget_Grid -{ - public function __construct() - { - parent::__construct(); - $this->setId('answersGrid'); - $this->setDefaultSort('answer_id'); - $this->setDefaultDir('ASC'); - $this->setUseAjax(true); - } - - protected function _prepareCollection() - { - $collection = Mage::getModel('poll/poll_answer') - ->getResourceCollection() - ->addPollFilter($this->getRequest()->getParam('id')); - $this->setCollection($collection); - return parent::_prepareCollection(); - } - - protected function _prepareColumns() - { - $this->addColumn('answer_id', [ - 'header' => Mage::helper('poll')->__('ID'), - 'align' => 'right', - 'width' => '50px', - 'index' => 'answer_id', - ]); - - $this->addColumn('answer_title', [ - 'header' => Mage::helper('poll')->__('Answer Title'), - 'align' => 'left', - 'index' => 'answer_title', - ]); - - $this->addColumn('votes_count', [ - 'header' => Mage::helper('poll')->__('Votes Count'), - 'type' => 'number', - 'width' => '50px', - 'index' => 'votes_count', - ]); - - $this->addColumn('actions', [ - 'header' => Mage::helper('poll')->__('Actions'), - 'align' => 'center', - 'type' => 'action', - 'width' => '10px', - 'filter' => false, - 'sortable' => false, - 'actions' => [ - [ - 'caption' => Mage::helper('poll')->__('Delete'), - 'onClick' => 'return answers.delete(\'$answer_id\')', - 'url' => '#', - ], - ], - ]); - - return parent::_prepareColumns(); - } - - public function getRowUrl($row) - { - return $this->getUrl('*/poll_answer/edit', ['id' => $row->getId()]); - } - - public function getGridUrl() - { - return $this->getUrl('*/poll_answer/grid', ['id' => $this->getRequest()->getParam('id')]); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php deleted file mode 100644 index bb1ec4abeea..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Answers/List.php +++ /dev/null @@ -1,83 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Edit_Tab_Answers_List extends Mage_Adminhtml_Block_Template -{ - public function __construct() - { - $this->setTemplate('poll/answers/list.phtml'); - } - - protected function _toHtml() - { - if (!Mage::registry('poll_data')) { - $this->assign('answers', false); - return parent::_toHtml(); - } - - $collection = Mage::getModel('poll/poll_answer') - ->getResourceCollection() - ->addPollFilter(Mage::registry('poll_data')->getId()) - ->load(); - $this->assign('answers', $collection); - - return parent::_toHtml(); - } - - protected function _prepareLayout() - { - $this->setChild( - 'deleteButton', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('poll')->__('Delete'), - 'onclick' => 'answer.del(this)', - 'class' => 'delete' - ]) - ); - - $this->setChild( - 'addButton', - $this->getLayout()->createBlock('adminhtml/widget_button') - ->setData([ - 'label' => Mage::helper('poll')->__('Add New Answer'), - 'onclick' => 'answer.add(this)', - 'class' => 'add' - ]) - ); - return parent::_prepareLayout(); - } - - public function getDeleteButtonHtml() - { - return $this->getChildHtml('deleteButton'); - } - - public function getAddButtonHtml() - { - return $this->getChildHtml('addButton'); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Form.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Form.php deleted file mode 100644 index 43d4b97d24b..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tab/Form.php +++ /dev/null @@ -1,91 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form -{ - protected function _prepareForm() - { - $form = new Varien_Data_Form(); - - $fieldset = $form->addFieldset('poll_form', ['legend' => Mage::helper('poll')->__('Poll information')]); - $fieldset->addField('poll_title', 'text', [ - 'label' => Mage::helper('poll')->__('Poll Question'), - 'class' => 'required-entry', - 'required' => true, - 'name' => 'poll_title', - ]); - - $fieldset->addField('closed', 'select', [ - 'label' => Mage::helper('poll')->__('Status'), - 'name' => 'closed', - 'values' => [ - [ - 'value' => 1, - 'label' => Mage::helper('poll')->__('Closed'), - ], - - [ - 'value' => 0, - 'label' => Mage::helper('poll')->__('Open'), - ], - ], - ]); - - if (!Mage::app()->isSingleStoreMode()) { - $fieldset->addField('store_ids', 'multiselect', [ - 'label' => Mage::helper('poll')->__('Visible In'), - 'required' => true, - 'name' => 'store_ids[]', - 'values' => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(), - 'value' => Mage::registry('poll_data')->getStoreIds() - ]); - } else { - $fieldset->addField('store_ids', 'hidden', [ - 'name' => 'store_ids[]', - 'value' => Mage::app()->getStore(true)->getId() - ]); - Mage::registry('poll_data')->setStoreIds(Mage::app()->getStore(true)->getId()); - } - - if (Mage::getSingleton('adminhtml/session')->getPollData()) { - $form->setValues(Mage::getSingleton('adminhtml/session')->getPollData()); - Mage::getSingleton('adminhtml/session')->setPollData(null); - } elseif (Mage::registry('poll_data')) { - $form->setValues(Mage::registry('poll_data')->getData()); - - $fieldset->addField('was_closed', 'hidden', [ - 'name' => 'was_closed', - 'no_span' => true, - 'value' => Mage::registry('poll_data')->getClosed() - ]); - } - - $this->setForm($form); - return parent::_prepareForm(); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tabs.php b/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tabs.php deleted file mode 100644 index 98ceeb235df..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Edit/Tabs.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs -{ - public function __construct() - { - parent::__construct(); - $this->setId('poll_tabs'); - $this->setDestElementId('edit_form'); - $this->setTitle(Mage::helper('poll')->__('Poll Information')); - } - - protected function _beforeToHtml() - { - $this->addTab('form_section', [ - 'label' => Mage::helper('poll')->__('Poll Information'), - 'title' => Mage::helper('poll')->__('Poll Information'), - 'content' => $this->getLayout()->createBlock('adminhtml/poll_edit_tab_form')->toHtml(), - ]) - ; - - $this->addTab('answers_section', [ - 'label' => Mage::helper('poll')->__('Poll Answers'), - 'title' => Mage::helper('poll')->__('Poll Answers'), - 'content' => $this->getLayout()->createBlock('adminhtml/poll_edit_tab_answers') - ->append($this->getLayout()->createBlock('adminhtml/poll_edit_tab_answers_list')) - ->toHtml(), - 'active' => $this->getRequest()->getParam('tab') == 'answers_section', - ]); - return parent::_beforeToHtml(); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Grid.php b/app/code/core/Mage/Adminhtml/Block/Poll/Grid.php deleted file mode 100644 index 3d4611ebb81..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Grid.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * @method Mage_Poll_Model_Resource_Poll_Collection getCollection() - */ -class Mage_Adminhtml_Block_Poll_Grid extends Mage_Adminhtml_Block_Widget_Grid -{ - /** - * Mage_Adminhtml_Block_Poll_Grid constructor. - */ - public function __construct() - { - parent::__construct(); - $this->setId('pollGrid'); - $this->setDefaultSort('poll_title'); - $this->setDefaultDir('ASC'); - $this->setSaveParametersInSession(true); - } - - /** - * @return $this - * @throws Mage_Core_Exception - */ - protected function _prepareCollection() - { - $collection = Mage::getModel('poll/poll')->getCollection(); - $this->setCollection($collection); - parent::_prepareCollection(); - - if (!Mage::app()->isSingleStoreMode()) { - $this->getCollection()->addStoreData(); - } - - return $this; - } - - /** - * @inheritDoc - * @throws Exception - */ - protected function _prepareColumns() - { - $this->addColumn('poll_id', [ - 'header' => Mage::helper('poll')->__('ID'), - 'align' => 'right', - 'width' => '50px', - 'index' => 'poll_id', - ]); - - $this->addColumn('poll_title', [ - 'header' => Mage::helper('poll')->__('Poll Question'), - 'align' => 'left', - 'index' => 'poll_title', - ]); - - $this->addColumn('votes_count', [ - 'header' => Mage::helper('poll')->__('Number of Responses'), - 'width' => '50px', - 'type' => 'number', - 'index' => 'votes_count', - ]); - - $this->addColumn('date_posted', [ - 'header' => Mage::helper('poll')->__('Date Posted'), - 'align' => 'left', - 'type' => 'datetime', - 'index' => 'date_posted', - 'format' => Mage::app()->getLocale()->getDateFormat() - ]); - - $this->addColumn('date_closed', [ - 'header' => Mage::helper('poll')->__('Date Closed'), - 'align' => 'left', - 'type' => 'datetime', - 'default' => '--', - 'index' => 'date_closed', - 'format' => Mage::app()->getLocale()->getDateFormat() - ]); - - if (!Mage::app()->isSingleStoreMode()) { - $this->addColumn('visible_in', [ - 'header' => Mage::helper('review')->__('Visible In'), - 'index' => 'stores', - 'type' => 'store', - 'store_view' => true, - 'sortable' => false, - ]); - } - - $this->addColumn('closed', [ - 'header' => Mage::helper('poll')->__('Status'), - 'align' => 'left', - 'width' => '80px', - 'index' => 'closed', - 'type' => 'options', - 'options' => [ - 1 => Mage::helper('poll')->__('Closed'), - 0 => Mage::helper('poll')->__('Open') - ], - ]); - - return parent::_prepareColumns(); - } - - /** - * @param Mage_Poll_Model_Poll $row - * @return string - */ - public function getRowUrl($row) - { - return $this->getUrl('*/*/edit', ['id' => $row->getId()]); - } -} diff --git a/app/code/core/Mage/Adminhtml/Block/Poll/Poll.php b/app/code/core/Mage/Adminhtml/Block/Poll/Poll.php deleted file mode 100644 index 37c9e390f7c..00000000000 --- a/app/code/core/Mage/Adminhtml/Block/Poll/Poll.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -class Mage_Adminhtml_Block_Poll_Poll extends Mage_Adminhtml_Block_Widget_Grid_Container -{ - public function __construct() - { - $this->_controller = 'poll'; - $this->_headerText = Mage::helper('poll')->__('Poll Manager'); - $this->_addButtonLabel = Mage::helper('poll')->__('Add New Poll'); - parent::__construct(); - } -} diff --git a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php b/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php deleted file mode 100644 index 03948eccafa..00000000000 --- a/app/code/core/Mage/Adminhtml/controllers/Poll/AnswerController.php +++ /dev/null @@ -1,133 +0,0 @@ - - */ -class Mage_Adminhtml_Poll_AnswerController extends Mage_Adminhtml_Controller_Action -{ - /** - * ACL resource - * @see Mage_Adminhtml_Controller_Action::_isAllowed() - */ - public const ADMIN_RESOURCE = 'cms/poll'; - - public function editAction() - { - $this->loadLayout(); - - $this->_setActiveMenu('cms/poll'); - $this->_addBreadcrumb( - Mage::helper('poll')->__('Poll Manager'), - Mage::helper('poll')->__('Poll Manager'), - $this->getUrl('*/*/') - ); - $this->_addBreadcrumb( - Mage::helper('poll')->__('Edit Poll Answer'), - Mage::helper('poll')->__('Edit Poll Answer') - ); - - $this->_addContent($this->getLayout()->createBlock('adminhtml/poll_answer_edit')); - - $this->renderLayout(); - } - - public function saveAction() - { - //print '@@'; - if ($post = $this->getRequest()->getPost()) { - try { - $model = Mage::getModel('poll/poll_answer'); - $model->setData($post) - ->setId($this->getRequest()->getParam('id')) - ->save(); - - Mage::getSingleton('adminhtml/session')->addSuccess( - Mage::helper('poll')->__('The answer has been saved.') - ); - $this->_redirect( - '*/poll/edit', - ['id' => $this->getRequest()->getParam('poll_id'), 'tab' => 'answers_section'] - ); - return; - } catch (Exception $e) { - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); - $this->_redirect('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); - return; - } - } - $this->_redirect('*/*/'); - } - - public function gridAction() - { - $this->getResponse()->setBody( - $this->getLayout()->createBlock('adminhtml/poll_edit_tab_answers_grid')->toHtml() - ); - } - - public function jsonSaveAction() - { - $response = new Varien_Object(); - $response->setError(0); - - if ($post = $this->getRequest()->getPost()) { - $data = Zend_Json::decode($post['data']); - try { - if (trim($data['answer_title']) == '') { - throw new Exception(Mage::helper('poll')->__('Invalid Answer.')); - } - $model = Mage::getModel('poll/poll_answer'); - $model->setData($data) - ->save(); - } catch (Exception $e) { - $response->setError(1); - $response->setMessage($e->getMessage()); - } - } - $this->getResponse()->setBody($response->toJson()); - } - - public function jsonDeleteAction() - { - $response = new Varien_Object(); - $response->setError(0); - - if ($id = $this->getRequest()->getParam('id')) { - try { - $model = Mage::getModel('poll/poll_answer'); - $model->setId(Zend_Json::decode($id)) - ->delete(); - } catch (Exception $e) { - $response->setError(1); - $response->setMessage($e->getMessage()); - } - } else { - $response->setError(1); - $response->setMessage(Mage::helper('poll')->__('Unable to find an answer to delete.')); - } - $this->getResponse()->setBody($response->toJson()); - } -} diff --git a/app/code/core/Mage/Adminhtml/controllers/PollController.php b/app/code/core/Mage/Adminhtml/controllers/PollController.php deleted file mode 100644 index 6005d9654f0..00000000000 --- a/app/code/core/Mage/Adminhtml/controllers/PollController.php +++ /dev/null @@ -1,205 +0,0 @@ - - */ -class Mage_Adminhtml_PollController extends Mage_Adminhtml_Controller_Action -{ - /** - * ACL resource - * @see Mage_Adminhtml_Controller_Action::_isAllowed() - */ - public const ADMIN_RESOURCE = 'cms/poll'; - - public function indexAction() - { - $this->_title($this->__('CMS'))->_title($this->__('Polls')); - - $this->loadLayout(); - $this->_setActiveMenu('cms/poll'); - $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Poll Manager'), Mage::helper('adminhtml')->__('Poll Manager')); - - $this->_addContent($this->getLayout()->createBlock('adminhtml/poll_poll')); - $this->renderLayout(); - } - - public function editAction() - { - $this->_title($this->__('CMS'))->_title($this->__('Polls')); - - $pollId = $this->getRequest()->getParam('id'); - $pollModel = Mage::getModel('poll/poll')->load($pollId); - - if ($pollModel->getId() || $pollId == 0) { - $this->_title($pollModel->getId() ? $pollModel->getPollTitle() : $this->__('New Poll')); - - Mage::register('poll_data', $pollModel); - - $this->loadLayout(); - $this->_setActiveMenu('cms/poll'); - $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Poll Manager'), Mage::helper('adminhtml')->__('Poll Manager'), $this->getUrl('*/*/')); - $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Edit Poll'), Mage::helper('adminhtml')->__('Edit Poll')); - - $this->getLayout()->getBlock('head')->setCanLoadExtJs(true); - $this->_addContent($this->getLayout()->createBlock('adminhtml/poll_edit')) - ->_addLeft($this->getLayout()->createBlock('adminhtml/poll_edit_tabs')); - - $this->renderLayout(); - } else { - Mage::getSingleton('adminhtml/session')->addError(Mage::helper('poll')->__('The poll does not exist.')); - $this->_redirect('*/*/'); - } - } - - public function deleteAction() - { - if ($id = $this->getRequest()->getParam('id')) { - try { - $model = Mage::getModel('poll/poll'); - $model->setId($id); - $model->delete(); - Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The poll has been deleted.')); - $this->_redirect('*/*/'); - return; - } catch (Exception $e) { - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); - $this->_redirect('*/*/edit', ['id' => $this->getRequest()->getParam('id')]); - return; - } - } - Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Unable to find a poll to delete.')); - $this->_redirect('*/*/'); - } - - public function saveAction() - { - Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The poll has been saved.')); - Mage::getSingleton('adminhtml/session')->setPollData(false); - $this->_redirect('*/*/'); - } - - public function newAction() - { - $this->getRequest()->setParam('id', 0); - $this->_forward('edit'); - } - - public function validateAction() - { - $response = new Varien_Object(); - $response->setError(false); - - if ($this->getRequest()->getPost()) { - try { - $pollModel = Mage::getModel('poll/poll'); - - $now = Varien_Date::now(); - if (!$this->getRequest()->getParam('id')) { - $pollModel->setDatePosted($now); - } - - if ($this->getRequest()->getParam('closed') && !$this->getRequest()->getParam('was_closed')) { - $pollModel->setDateClosed($now); - } - - if (!$this->getRequest()->getParam('closed')) { - $pollModel->setDateClosed(new Zend_Db_Expr('null')); - } - - $pollModel->setPollTitle($this->getRequest()->getParam('poll_title')) - ->setClosed($this->getRequest()->getParam('closed')); - - if ($this->getRequest()->getParam('id') > 0) { - $pollModel->setId($this->getRequest()->getParam('id')); - } - - $stores = $this->getRequest()->getParam('store_ids'); - if (!is_array($stores) || count($stores) == 0) { - Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.')); - } - - $storeIds = []; - foreach ($stores as $storeIdList) { - $storeIdList = explode(',', $storeIdList); - if (!$storeIdList) { - continue; - } - foreach ($storeIdList as $storeId) { - if ($storeId > 0) { - $storeIds[] = $storeId; - } - } - } - if (count($storeIds) === 0) { - Mage::throwException(Mage::helper('adminhtml')->__('Please, select "Visible in Stores" for this poll first.')); - } - $pollModel->setStoreIds($storeIds); - - $answers = $this->getRequest()->getParam('answer'); - - if (!is_array($answers) || !count($answers)) { - Mage::throwException(Mage::helper('adminhtml')->__('Please, add some answers to this poll first.')); - } - - $_titles = []; - foreach ($answers as $key => $answer) { - if (in_array($answer['title'], $_titles)) { - Mage::throwException(Mage::helper('adminhtml')->__('Your answers contain duplicates.')); - } - $_titles[] = $answer['title']; - - $answerModel = Mage::getModel('poll/poll_answer'); - if ((int) $key > 0) { - $answerModel->setId($key); - } - $answerModel->setAnswerTitle($answer['title']) - ->setVotesCount($answer['votes']); - - $pollModel->addAnswer($answerModel); - } - - $pollModel->save(); - - Mage::register('current_poll_model', $pollModel); - - $answersDelete = $this->getRequest()->getParam('deleteAnswer'); - if (is_array($answersDelete)) { - foreach ($answersDelete as $answer) { - $answerModel = Mage::getModel('poll/poll_answer'); - $answerModel->setId($answer) - ->delete(); - } - } - } catch (Exception $e) { - Mage::getSingleton('adminhtml/session')->addError($e->getMessage()); - $this->_initLayoutMessages('adminhtml/session'); - $response->setError(true); - $response->setMessage($this->getLayout()->getMessagesBlock()->getGroupedHtml()); - } - } - $this->getResponse()->setBody($response->toJson()); - } -} diff --git a/app/code/core/Mage/Poll/Block/ActivePoll.php b/app/code/core/Mage/Poll/Block/ActivePoll.php deleted file mode 100644 index 6947f36e36c..00000000000 --- a/app/code/core/Mage/Poll/Block/ActivePoll.php +++ /dev/null @@ -1,246 +0,0 @@ - - */ -class Mage_Poll_Block_ActivePoll extends Mage_Core_Block_Template -{ - /** - * Poll templates - * - * @var array - */ - protected $_templates; - - /** - * Current Poll Id - * - * @var int - */ - protected $_pollId = null; - - /** - * Already voted by current visitor Poll Ids array - * - * @var array|null - */ - protected $_votedIds = null; - - /** - * Poll model - * - * @var Mage_Poll_Model_Poll - */ - protected $_pollModel; - - public function __construct() - { - parent::__construct(); - $this->_pollModel = Mage::getModel('poll/poll'); - } - - /** - * Set current Poll Id - * - * @param int $pollId - * @return $this - */ - public function setPollId($pollId) - { - $this->_pollId = $pollId; - return $this; - } - - /** - * Get current Poll Id - * - * @return int - */ - public function getPollId() - { - return $this->_pollId; - } - - /** - * Retrieve already voted Poll Ids - * - * @return array|null - */ - public function getVotedPollsIds() - { - if ($this->_votedIds === null) { - $this->_votedIds = $this->_pollModel->getVotedPollsIds(); - } - return $this->_votedIds; - } - - /** - * Get Ids of all active Polls - * - * @return array - */ - public function getActivePollsIds() - { - return $this->_pollModel - ->setExcludeFilter($this->getVotedPollsIds()) - ->setStoreFilter(Mage::app()->getStore()->getId()) - ->getAllIds(); - } - - /** - * Get Poll Id to show - * - * @return int - */ - public function getPollToShow() - { - if ($this->getPollId()) { - return $this->getPollId(); - } - // get last voted poll (from session only) - $pollId = Mage::getSingleton('core/session')->getJustVotedPoll(); - if (empty($pollId)) { - // get random not voted yet poll - $votedIds = $this->getVotedPollsIds(); - $pollId = $this->_pollModel - ->setExcludeFilter($votedIds) - ->setStoreFilter(Mage::app()->getStore()->getId()) - ->getRandomId(); - } - $this->setPollId($pollId); - - return $pollId; - } - - /** - * Get Poll related data - * - * @param int $pollId - * @return array|false - */ - public function getPollData($pollId) - { - if (empty($pollId)) { - return false; - } - - $poll = $this->_pollModel->load($pollId); - $pollAnswers = Mage::getModel('poll/poll_answer') - ->getResourceCollection() - ->addPollFilter($pollId) - ->load() - ->countPercent($poll); - - // correct rounded percents to be always equal 100 - $percentsSorted = []; - $answersArr = []; - $key = null; - - /** - * @var int $key - * @var Mage_Poll_Model_Poll_Answer $answer - */ - foreach ($pollAnswers as $key => $answer) { - $percentsSorted[$key] = $answer->getPercent(); - $answersArr[$key] = $answer; - } - - $total = 0; - $value = 0; - - asort($percentsSorted); - foreach ($percentsSorted as $key => $value) { - $total += $value; - } - - // change the max value only - if ($total > 0 && $total !== 100) { - $answersArr[$key]->setPercent($value + 100 - $total); - } - - return [ - 'poll' => $poll, - 'poll_answers' => $pollAnswers, - 'action' => Mage::getUrl('poll/vote/add', ['poll_id' => $pollId, '_secure' => true]) - ]; - } - - /** - * Add poll template - * - * @param string $template - * @param string $type - * @return $this - */ - public function setPollTemplate($template, $type) - { - $this->_templates[$type] = $template; - return $this; - } - - /** - * Render block HTML - * - * @return string - */ - protected function _toHtml() - { - /** @var Mage_Core_Model_Session $coreSessionModel */ - $coreSessionModel = Mage::getSingleton('core/session'); - $justVotedPollId = $coreSessionModel->getJustVotedPoll(); - if ($justVotedPollId && !$this->_pollModel->isVoted($justVotedPollId)) { - $this->_pollModel->setVoted($justVotedPollId); - } - - $pollId = $this->getPollToShow(); - $data = $this->getPollData($pollId); - $this->assign($data); - - $coreSessionModel->setJustVotedPoll(false); - - if ($this->_pollModel->isVoted($pollId) === true || $justVotedPollId) { - $this->setTemplate($this->_templates['results']); - } else { - $this->setTemplate($this->_templates['poll']); - } - return parent::_toHtml(); - } - - /** - * Get cache key informative items that must be preserved in cache placeholders - * for block to be rerendered by placeholder - * - * @return array - */ - public function getCacheKeyInfo() - { - $items = [ - 'templates' => serialize($this->_templates) - ]; - - $items = parent::getCacheKeyInfo() + $items; - - return $items; - } -} diff --git a/app/code/core/Mage/Poll/Block/Poll.php b/app/code/core/Mage/Poll/Block/Poll.php deleted file mode 100644 index e45772c2cd4..00000000000 --- a/app/code/core/Mage/Poll/Block/Poll.php +++ /dev/null @@ -1,33 +0,0 @@ - - */ -class Mage_Poll_Block_Poll extends Mage_Core_Block_Template -{ - public function __construct() - { - parent::__construct(); - $this->setTemplate('poll/poll.phtml'); - } -} diff --git a/app/code/core/Mage/Poll/Helper/Data.php b/app/code/core/Mage/Poll/Helper/Data.php deleted file mode 100644 index 74a2fdf0212..00000000000 --- a/app/code/core/Mage/Poll/Helper/Data.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ -class Mage_Poll_Helper_Data extends Mage_Core_Helper_Abstract -{ - protected $_moduleName = 'Mage_Poll'; -} diff --git a/app/code/core/Mage/Poll/Model/Mysql4/Poll.php b/app/code/core/Mage/Poll/Model/Mysql4/Poll.php deleted file mode 100644 index 4dcf14030b6..00000000000 --- a/app/code/core/Mage/Poll/Model/Mysql4/Poll.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @deprecated - */ -class Mage_Poll_Model_Mysql4_Poll extends Mage_Poll_Model_Resource_Poll -{ -} diff --git a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Answer.php b/app/code/core/Mage/Poll/Model/Mysql4/Poll/Answer.php deleted file mode 100644 index 6c6cb6945f3..00000000000 --- a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Answer.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @deprecated - */ -class Mage_Poll_Model_Mysql4_Poll_Answer extends Mage_Poll_Model_Resource_Poll_Answer -{ -} diff --git a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Answer/Collection.php b/app/code/core/Mage/Poll/Model/Mysql4/Poll/Answer/Collection.php deleted file mode 100644 index f5ca4d3883a..00000000000 --- a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Answer/Collection.php +++ /dev/null @@ -1,30 +0,0 @@ - - * @deprecated - */ -class Mage_Poll_Model_Mysql4_Poll_Answer_Collection extends Mage_Poll_Model_Resource_Poll_Answer_Collection -{ -} diff --git a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Collection.php b/app/code/core/Mage/Poll/Model/Mysql4/Poll/Collection.php deleted file mode 100644 index 6b29ddaae8c..00000000000 --- a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Collection.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @deprecated - */ -class Mage_Poll_Model_Mysql4_Poll_Collection extends Mage_Poll_Model_Resource_Poll_Collection -{ -} diff --git a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Vote.php b/app/code/core/Mage/Poll/Model/Mysql4/Poll/Vote.php deleted file mode 100644 index af5e474a13d..00000000000 --- a/app/code/core/Mage/Poll/Model/Mysql4/Poll/Vote.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @deprecated - */ -class Mage_Poll_Model_Mysql4_Poll_Vote extends Mage_Poll_Model_Resource_Poll_Vote -{ -} diff --git a/app/code/core/Mage/Poll/Model/Poll.php b/app/code/core/Mage/Poll/Model/Poll.php deleted file mode 100644 index cca707a88ea..00000000000 --- a/app/code/core/Mage/Poll/Model/Poll.php +++ /dev/null @@ -1,314 +0,0 @@ - - * - * @method Mage_Poll_Model_Resource_Poll _getResource() - * @method Mage_Poll_Model_Resource_Poll getResource() - * @method Mage_Poll_Model_Resource_Poll_Collection getCollection() - * - * @method int getActive() - * @method $this setActive(int $value) - * @method int getAnswersDisplay() - * @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) - */ -class Mage_Poll_Model_Poll extends Mage_Core_Model_Abstract -{ - public const XML_PATH_POLL_CHECK_BY_IP = 'web/polls/poll_check_by_ip'; - - protected $_pollCookieDefaultName = 'poll'; - - /** - * @var Mage_Poll_Model_Poll_Answer[] - */ - protected $_answersCollection = []; - protected $_storeCollection = []; - - protected function _construct() - { - $this->_init('poll/poll'); - } - - /** - * Retrieve Cookie Object - * - * @return Mage_Core_Model_Cookie - */ - public function getCookie() - { - return Mage::app()->getCookie(); - } - - /** - * Get Cookie Name - * - * @param int $pollId - * @return string - */ - public function getCookieName($pollId = null) - { - return $this->_pollCookieDefaultName . $this->getPollId($pollId); - } - - /** - * Retrieve defined or current Id - * - * @deprecated since 1.7.0.0 - * @param int $pollId - * @return int - */ - public function getPoolId($pollId = null) - { - return $this->getPollId($pollId); - } - - /** - * Retrieve defined or current Id - * - * @param int|string|null $pollId - * @return int|string - */ - public function getPollId($pollId = null) - { - if (is_null($pollId)) { - $pollId = $this->getId(); - } - return $pollId; - } - - /** - * Check if validation by IP option is enabled in config - * - * @return bool - */ - public function isValidationByIp() - { - return (Mage::getStoreConfig(self::XML_PATH_POLL_CHECK_BY_IP) == 1); - } - - /** - * Declare poll as voted - * - * @param int $pollId - * @return $this - */ - public function setVoted($pollId = null) - { - $this->getCookie()->set($this->getCookieName($pollId), $this->getPollId($pollId)); - - return $this; - } - - /** - * Check if poll is voted - * - * @param int $pollId - * @return bool - */ - public function isVoted($pollId = null) - { - $pollId = $this->getPollId($pollId); - - // check if it is in cookie - $cookie = $this->getCookie()->get($this->getCookieName($pollId)); - if ($cookie !== false) { - return true; - } - - // check by ip - if (count($this->_getResource()->getVotedPollIdsByIp(Mage::helper('core/http')->getRemoteAddr(), $pollId))) { - return true; - } - - return false; - } - - /** - * Get random active pool identifier - * - * @return string - */ - public function getRandomId() - { - return $this->_getResource()->getRandomId($this); - } - - /** - * Get all ids for not closed polls - * - * @return array - */ - public function getAllIds() - { - return $this->_getResource()->getAllIds($this); - } - - /** - * Add vote to poll - * - * @param Mage_Poll_Model_Poll_Vote $vote - * @return $this - * @throws Exception - */ - public function addVote(Mage_Poll_Model_Poll_Vote $vote) - { - if ($this->hasAnswer($vote->getPollAnswerId())) { - $vote->setPollId($this->getId()) - ->save(); - $this->setVoted(); - } - return $this; - } - - /** - * Check answer existing for poll - * - * @param Mage_Poll_Model_Poll_Answer|string|int $answer - * @return string|false - */ - public function hasAnswer($answer) - { - $answerId = false; - if (is_numeric($answer)) { - $answerId = $answer; - } elseif ($answer instanceof Mage_Poll_Model_Poll_Answer) { - $answerId = $answer->getId(); - } - - if ($answerId) { - return $this->_getResource()->checkAnswerId($this, $answerId); - } - return false; - } - - /** - * @return $this - */ - public function resetVotesCount() - { - $this->_getResource()->resetVotesCount($this); - return $this; - } - - /** - * @return array - */ - public function getVotedPollsIds() - { - $idsArray = []; - - foreach ($this->getCookie()->get() as $cookieName => $cookieValue) { - $pattern = '#^' . preg_quote($this->_pollCookieDefaultName, '#') . '(\d+)$#'; - $match = []; - if (preg_match($pattern, $cookieName, $match)) { - if ($match[1] != Mage::getSingleton('core/session')->getJustVotedPoll()) { - $idsArray[$match[1]] = $match[1]; - } - } - } - - // load from db for this ip - foreach ($this->_getResource()->getVotedPollIdsByIp(Mage::helper('core/http')->getRemoteAddr()) as $pollId) { - $idsArray[$pollId] = $pollId; - } - - 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(); - if (!in_array($storeId, $ids)) { - $ids[] = $storeId; - } - $this->setStoreIds($ids); - return $this; - } - - /** - * @return array - */ - public function getStoreIds() - { - $ids = $this->_getData('store_ids'); - if (is_null($ids)) { - $this->loadStoreIds(); - $ids = $this->getData('store_ids'); - } - return $ids; - } - - public function loadStoreIds() - { - $this->_getResource()->loadStoreIds($this); - } - - /** - * @return int - */ - public function getVotesCount() - { - return $this->_getData('votes_count'); - } -} diff --git a/app/code/core/Mage/Poll/Model/Poll/Answer.php b/app/code/core/Mage/Poll/Model/Poll/Answer.php deleted file mode 100644 index b86dca6ca8d..00000000000 --- a/app/code/core/Mage/Poll/Model/Poll/Answer.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * @method Mage_Poll_Model_Resource_Poll_Answer _getResource() - * @method Mage_Poll_Model_Resource_Poll_Answer getResource() - * @method Mage_Poll_Model_Resource_Poll_Answer_Collection getCollection() - * @method Mage_Poll_Model_Resource_Poll_Answer_Collection getResourceCollection() - * - * @method int getAnswerOrder() - * @method $this setAnswerOrder(int $value) - * @method string getAnswerTitle() - * @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 $this setVotesCount(int $value) - */ -class Mage_Poll_Model_Poll_Answer extends Mage_Core_Model_Abstract -{ - protected function _construct() - { - $this->_init('poll/poll_answer'); - } - - /** - * @param Mage_Poll_Model_Poll $poll - * @return $this - */ - public function countPercent($poll) - { - $this->setPercent( - round(($poll->getVotesCount() > 0) ? ($this->getVotesCount() * 100 / $poll->getVotesCount()) : 0, 2) - ); - return $this; - } - - /** - * @inheritDoc - */ - protected function _afterSave() - { - Mage::getModel('poll/poll') - ->setId($this->getPollId()) - ->resetVotesCount(); - return parent::_afterSave(); - } - - /** - * @inheritDoc - */ - protected function _beforeDelete() - { - $this->setPollId($this->load($this->getId())->getPollId()); - return parent::_beforeDelete(); - } - - /** - * @inheritDoc - */ - protected function _afterDelete() - { - Mage::getModel('poll/poll') - ->setId($this->getPollId()) - ->resetVotesCount(); - return parent::_afterDelete(); - } -} diff --git a/app/code/core/Mage/Poll/Model/Poll/Vote.php b/app/code/core/Mage/Poll/Model/Poll/Vote.php deleted file mode 100644 index 3e177bcf018..00000000000 --- a/app/code/core/Mage/Poll/Model/Poll/Vote.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * @method Mage_Poll_Model_Resource_Poll_Vote _getResource() - * @method Mage_Poll_Model_Resource_Poll_Vote getResource() - * - * @method int getPollId() - * @method $this setPollId(int $value) - * @method int getPollAnswerId() - * @method $this setPollAnswerId(int $value) - * @method int getIpAddress() - * @method $this setIpAddress(int $value) - * @method int getCustomerId() - * @method $this setCustomerId(int $value) - * @method string getVoteTime() - * @method $this setVoteTime(string $value) - */ -class Mage_Poll_Model_Poll_Vote extends Mage_Core_Model_Abstract -{ - protected function _construct() - { - $this->_init('poll/poll_vote'); - } - - /** - * Processing object before save data - * - * @return Mage_Core_Model_Abstract - */ - protected function _beforeSave() - { - if (!$this->getVoteTime()) { - $this->setVoteTime(Mage::getSingleton('core/date')->gmtDate()); - } - return parent::_beforeSave(); - } -} diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll.php b/app/code/core/Mage/Poll/Model/Resource/Poll.php deleted file mode 100644 index 305b51c1579..00000000000 --- a/app/code/core/Mage/Poll/Model/Resource/Poll.php +++ /dev/null @@ -1,235 +0,0 @@ - - */ -class Mage_Poll_Model_Resource_Poll extends Mage_Core_Model_Resource_Db_Abstract -{ - /** - * Initialize resource - * - */ - protected function _construct() - { - $this->_init('poll/poll', 'poll_id'); - } - - /** - * Initialize unique fields - * - * @return $this - */ - protected function _initUniqueFields() - { - $this->_uniqueFields = [[ - 'field' => 'poll_title', - 'title' => Mage::helper('poll')->__('Poll with the same question') - ]]; - return $this; - } - - /** - * Get select object for not closed poll ids - * - * @param Mage_Poll_Model_Poll $object - * @return Varien_Db_Select - */ - protected function _getSelectIds($object) - { - $read = $this->_getReadAdapter(); - $select = $read->select() - ->from(['main_table' => $this->getMainTable()], $this->getIdFieldName()) - ->where('closed = ?', 0); - - $excludeIds = $object->getExcludeFilter(); - if ($excludeIds) { - $select->where('main_table.poll_id NOT IN(?)', $excludeIds); - } - - $storeId = $object->getStoreFilter(); - if ($storeId) { - $select->join( - ['store' => $this->getTable('poll/poll_store')], - 'main_table.poll_id=store.poll_id AND store.store_id = ' . $read->quote($storeId), - [] - ); - } - - return $select; - } - - /** - * Get random identifier not closed poll - * - * @param Mage_Poll_Model_Poll $object - * @return string - */ - public function getRandomId($object) - { - $select = $this->_getSelectIds($object)->orderRand()->limit(1); - return $this->_getReadAdapter()->fetchOne($select); - } - - /** - * Get all ids for not closed polls - * - * @param Mage_Poll_Model_Poll $object - * @return array - */ - public function getAllIds($object) - { - $select = $this->_getSelectIds($object); - return $this->_getReadAdapter()->fetchCol($select); - } - - /** - * Check answer id existing for poll - * - * @param Mage_Poll_Model_Poll $poll - * @param int $answerId - * @return string - */ - public function checkAnswerId($poll, $answerId) - { - $select = $this->_getReadAdapter()->select() - ->from($this->getTable('poll_answer'), 'answer_id') - ->where('poll_id = :poll_id') - ->where('answer_id = :answer_id'); - $bind = [':poll_id' => $poll->getId(), ':answer_id' => $answerId]; - return $this->_getReadAdapter()->fetchOne($select, $bind); - } - - /** - * Get voted poll ids by specified IP-address - * Will return non-empty only if appropriate option in config is enabled - * If poll id is not empty, it will look only for records with specified value - * - * @param string $ipAddress - * @param int|false $pollId - * @return array - */ - public function getVotedPollIdsByIp($ipAddress, $pollId = false) - { - // check if validation by ip is enabled - if (!Mage::getModel('poll/poll')->isValidationByIp()) { - return []; - } - - // look for ids in database - $select = $this->_getReadAdapter()->select() - ->distinct() - ->from($this->getTable('poll_vote'), 'poll_id') - ->where('ip_address = ?', inet_pton($ipAddress)); - if (!empty($pollId)) { - $select->where('poll_id = ?', $pollId); - } - $result = $this->_getReadAdapter()->fetchCol($select); - if (empty($result)) { - $result = []; - } - return $result; - } - - /** - * Resett votes count - * - * @param Mage_Poll_Model_Poll $object - * @return Mage_Poll_Model_Poll - */ - public function resetVotesCount($object) - { - $adapter = $this->_getWriteAdapter(); - $select = $adapter->select() - ->from($this->getTable('poll_answer'), new Zend_Db_Expr("SUM(votes_count)")) - ->where('poll_id = ?', $object->getPollId()); - $adapter->update( - $this->getMainTable(), - ['votes_count' => new Zend_Db_Expr("($select)")], - ['poll_id = ' . $adapter->quote($object->getPollId())] - ); - return $object; - } - - /** - * Load store Ids array - * - * @param Mage_Poll_Model_Poll $object - */ - public function loadStoreIds(Mage_Poll_Model_Poll $object) - { - $pollId = $object->getId(); - $storeIds = []; - if ($pollId) { - $storeIds = $this->lookupStoreIds($pollId); - } - $object->setStoreIds($storeIds); - } - - /** - * Delete current poll from the table poll_store and then - * insert to update "poll to store" relations - * - * @param Mage_Core_Model_Abstract|Mage_Poll_Model_Poll $object - * @return $this - */ - public function _afterSave(Mage_Core_Model_Abstract $object) - { - /** stores */ - $deleteWhere = $this->_getWriteAdapter()->quoteInto('poll_id = ?', $object->getId()); - $this->_getWriteAdapter()->delete($this->getTable('poll/poll_store'), $deleteWhere); - - foreach ($object->getStoreIds() as $storeId) { - $pollStoreData = [ - 'poll_id' => $object->getId(), - 'store_id' => $storeId - ]; - $this->_getWriteAdapter()->insert($this->getTable('poll/poll_store'), $pollStoreData); - } - - /** answers */ - foreach ($object->getAnswers() as $answer) { - $answer->setPollId($object->getId()); - $answer->save(); - } - return $this; - } - - /** - * Get store ids to which specified item is assigned - * - * @param int $id - * @return array - */ - public function lookupStoreIds($id) - { - return $this->_getReadAdapter()->fetchCol( - $this->_getReadAdapter()->select() - ->from($this->getTable('poll/poll_store'), 'store_id') - ->where("{$this->getIdFieldName()} = :id_field"), - [':id_field' => $id] - ); - } -} diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll/Answer.php b/app/code/core/Mage/Poll/Model/Resource/Poll/Answer.php deleted file mode 100644 index 902d6e19364..00000000000 --- a/app/code/core/Mage/Poll/Model/Resource/Poll/Answer.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ -class Mage_Poll_Model_Resource_Poll_Answer extends Mage_Core_Model_Resource_Db_Abstract -{ - /** - * Initialize Poll_Answer resource - * - */ - protected function _construct() - { - $this->_init('poll/poll_answer', 'answer_id'); - } - - /** - * Initialize unique fields - * - * @return $this - */ - protected function _initUniqueFields() - { - $this->_uniqueFields = [[ - 'field' => ['answer_title', 'poll_id'], - 'title' => Mage::helper('poll')->__('Answer with the same title in this poll') - ]]; - return $this; - } -} diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll/Answer/Collection.php b/app/code/core/Mage/Poll/Model/Resource/Poll/Answer/Collection.php deleted file mode 100644 index 88c749ad0fc..00000000000 --- a/app/code/core/Mage/Poll/Model/Resource/Poll/Answer/Collection.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * @method Mage_Poll_Model_Poll_Answer[] getItems() - */ -class Mage_Poll_Model_Resource_Poll_Answer_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract -{ - /** - * Initialize collection - * - */ - public function _construct() - { - $this->_init('poll/poll_answer'); - } - - /** - * Add poll filter - * - * @param int $pollId - * @return $this - */ - public function addPollFilter($pollId) - { - $this->getSelect()->where("poll_id IN(?) ", $pollId); - return $this; - } - - /** - * Count percent - * - * @param Mage_Poll_Model_Poll $pollObject - * @return $this - */ - public function countPercent($pollObject) - { - if (!$pollObject) { - return $this; - } else { - foreach ($this->getItems() as $answer) { - $answer->countPercent($pollObject); - } - } - return $this; - } -} diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll/Collection.php b/app/code/core/Mage/Poll/Model/Resource/Poll/Collection.php deleted file mode 100644 index 66c159a4c79..00000000000 --- a/app/code/core/Mage/Poll/Model/Resource/Poll/Collection.php +++ /dev/null @@ -1,147 +0,0 @@ - - * - * @method int getId() - * @method $this setSelectStores(array $value) - */ -class Mage_Poll_Model_Resource_Poll_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract -{ - /** - * Initialize collection - * - */ - public function _construct() - { - $this->_init('poll/poll'); - } - - /** - * Redefine default filters - * - * @param string $field - * @param mixed $condition - * @return Varien_Data_Collection_Db - */ - public function addFieldToFilter($field, $condition = null) - { - if ($field == 'stores') { - return $this->addStoresFilter($condition); - } else { - return parent::addFieldToFilter($field, $condition); - } - } - - /** - * Add store filter - * - * @deprecated - * @param mixed $store - * @return $this - */ - public function addStoresFilter($store) - { - return $this->addStoreFilter($store); - } - - /** - * Add Stores Filter - * - * @param mixed $storeId - * @param bool $withAdmin - * @return $this - */ - public function addStoreFilter($storeId, $withAdmin = true) - { - $this->getSelect()->join( - ['store_table' => $this->getTable('poll/poll_store')], - 'main_table.poll_id = store_table.poll_id', - [] - ) - ->where('store_table.store_id in (?)', ($withAdmin ? [0, $storeId] : $storeId)) - ->group('main_table.poll_id'); - - /* - * Allow analytic functions usage - */ - $this->_useAnalyticFunction = true; - - return $this; - } - - /** - * Add stores data - * - * @return $this - */ - public function addStoreData() - { - $pollIds = $this->getColumnValues('poll_id'); - $storesToPoll = []; - - if (count($pollIds) > 0) { - $select = $this->getConnection()->select() - ->from($this->getTable('poll/poll_store')) - ->where('poll_id IN(?)', $pollIds); - $result = $this->getConnection()->fetchAll($select); - - foreach ($result as $row) { - if (!isset($storesToPoll[$row['poll_id']])) { - $storesToPoll[$row['poll_id']] = []; - } - $storesToPoll[$row['poll_id']][] = $row['store_id']; - } - } - - foreach ($this as $item) { - if (isset($storesToPoll[$item->getId()])) { - $item->setStores($storesToPoll[$item->getId()]); - } else { - $item->setStores([]); - } - } - - return $this; - } - - /** - * Set stores of the current poll - * - * @return $this - */ - public function addSelectStores() - { - $pollId = $this->getId(); - $select = $this->getConnection()->select() - ->from($this->getTable('poll/poll_store'), ['stor_id']) - ->where('poll_id = :poll_id'); - $stores = $this->getConnection()->fetchCol($select, [':poll_id' => $pollId]); - $this->setSelectStores($stores); - - return $this; - } -} diff --git a/app/code/core/Mage/Poll/Model/Resource/Poll/Vote.php b/app/code/core/Mage/Poll/Model/Resource/Poll/Vote.php deleted file mode 100644 index 9c05a17d4c2..00000000000 --- a/app/code/core/Mage/Poll/Model/Resource/Poll/Vote.php +++ /dev/null @@ -1,65 +0,0 @@ - - */ -class Mage_Poll_Model_Resource_Poll_Vote extends Mage_Core_Model_Resource_Db_Abstract -{ - /** - * Initialize vote resource - * - */ - protected function _construct() - { - $this->_init('poll/poll_vote', 'vote_id'); - } - - /** - * Perform actions after object save - * - * @param Mage_Core_Model_Abstract|Mage_Poll_Model_Poll_Vote $object - * @return $this - */ - protected function _afterSave(Mage_Core_Model_Abstract $object) - { - /** - * Increase answer votes - */ - $answerTable = $this->getTable('poll/poll_answer'); - $pollAnswerData = ['votes_count' => new Zend_Db_Expr('votes_count+1')]; - $condition = ["{$answerTable}.answer_id=?" => $object->getPollAnswerId()]; - $this->_getWriteAdapter()->update($answerTable, $pollAnswerData, $condition); - - /** - * Increase poll votes - */ - $pollTable = $this->getTable('poll/poll'); - $pollData = ['votes_count' => new Zend_Db_Expr('votes_count+1')]; - $condition = ["{$pollTable}.poll_id=?" => $object->getPollId()]; - $this->_getWriteAdapter()->update($pollTable, $pollData, $condition); - return $this; - } -} diff --git a/app/code/core/Mage/Poll/controllers/VoteController.php b/app/code/core/Mage/Poll/controllers/VoteController.php deleted file mode 100644 index 1fc48868ae5..00000000000 --- a/app/code/core/Mage/Poll/controllers/VoteController.php +++ /dev/null @@ -1,70 +0,0 @@ - - */ -class Mage_Poll_VoteController extends Mage_Core_Controller_Front_Action -{ - /** - * Action list where need check enabled cookie - * - * @var array - */ - protected $_cookieCheckActions = ['add']; - - /** - * Add Vote to Poll - */ - public function addAction() - { - $pollId = (int) $this->getRequest()->getParam('poll_id'); - $answerId = (int) $this->getRequest()->getParam('vote'); - - /** @var Mage_Poll_Model_Poll $poll */ - $poll = Mage::getModel('poll/poll')->load($pollId); - - /** - * Check poll data - */ - if ($poll->getId() && !$poll->getClosed() && !$poll->isVoted()) { - $vote = Mage::getModel('poll/poll_vote') - ->setPollAnswerId($answerId) - ->setIpAddress(Mage::helper('core/http')->getRemoteAddr(true)) - ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId()); - - $poll->addVote($vote); - Mage::getSingleton('core/session')->setJustVotedPoll($pollId); - Mage::dispatchEvent( - 'poll_vote_add', - [ - 'poll' => $poll, - 'vote' => $vote - ] - ); - } - $this->_redirectReferer(); - } -} diff --git a/app/code/core/Mage/Poll/data/poll_setup/data-install-1.6.0.0.php b/app/code/core/Mage/Poll/data/poll_setup/data-install-1.6.0.0.php deleted file mode 100644 index cdcb2998e6c..00000000000 --- a/app/code/core/Mage/Poll/data/poll_setup/data-install-1.6.0.0.php +++ /dev/null @@ -1,46 +0,0 @@ -setDatePosted(Varien_Date::now()) - ->setPollTitle('What is your favorite color') - ->setStoreIds([1]); - -$answers = [ - ['Green', 4], - ['Red', 1], - ['Black', 0], - ['Magenta', 2] -]; - -foreach ($answers as $key => $answer) { - $answerModel = Mage::getModel('poll/poll_answer'); - $answerModel->setAnswerTitle($answer[0]) - ->setVotesCount($answer[1]); - - $pollModel->addAnswer($answerModel); -} - -$pollModel->save(); diff --git a/app/code/core/Mage/Poll/etc/adminhtml.xml b/app/code/core/Mage/Poll/etc/adminhtml.xml deleted file mode 100644 index 6da4b422066..00000000000 --- a/app/code/core/Mage/Poll/etc/adminhtml.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - Polls - adminhtml/poll - 20 - - - - - - - - - - - - Polls - 20 - - - - - - - - diff --git a/app/code/core/Mage/Poll/etc/config.xml b/app/code/core/Mage/Poll/etc/config.xml deleted file mode 100644 index 784739c9972..00000000000 --- a/app/code/core/Mage/Poll/etc/config.xml +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - 1.6.0.1 - - - - - - standard - - Mage_Poll - poll - - - - - - - - Mage_Poll.csv - - - - - - - - poll.xml - - - - - - - - - - Mage_Poll.csv - - - - - - - - - Mage_Poll_Model - poll_resource - - - Mage_Poll_Model_Resource - poll_mysql4 - - - poll
-
- - poll_answer
-
- - poll_vote
-
- - poll_store
-
-
-
-
- - - - Mage_Poll - - - - - - Mage_Poll_Block - - -
-
diff --git a/app/code/core/Mage/Poll/etc/system.xml b/app/code/core/Mage/Poll/etc/system.xml deleted file mode 100644 index a656290de5e..00000000000 --- a/app/code/core/Mage/Poll/etc/system.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - select - adminhtml/system_config_source_yesno - 1 - 1 - 1 - 1 - - - - - - - diff --git a/app/code/core/Mage/Poll/sql/poll_setup/install-1.6.0.0.php b/app/code/core/Mage/Poll/sql/poll_setup/install-1.6.0.0.php deleted file mode 100644 index d27e452a851..00000000000 --- a/app/code/core/Mage/Poll/sql/poll_setup/install-1.6.0.0.php +++ /dev/null @@ -1,208 +0,0 @@ -startSetup(); - -/** - * Create table 'poll' - */ -$table = $installer->getConnection() - ->newTable($installer->getTable('poll/poll')) - ->addColumn('poll_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ], 'Poll Id') - ->addColumn('poll_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ - ], 'Poll title') - ->addColumn('votes_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Votes Count') - ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Store id') - ->addColumn('date_posted', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - 'nullable' => false, - ], 'Date posted') - ->addColumn('date_closed', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - 'nullable' => true, - ], 'Date closed') - ->addColumn('active', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'nullable' => false, - 'default' => '1', - ], 'Is active') - ->addColumn('closed', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'nullable' => false, - 'default' => '0', - ], 'Is closed') - ->addColumn('answers_display', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'nullable' => true, - ], 'Answers display') - ->addIndex( - $installer->getIdxName('poll/poll', ['store_id']), - ['store_id'] - ) - ->addForeignKey( - $installer->getFkName('poll/poll', 'store_id', 'core/store', 'store_id'), - 'store_id', - $installer->getTable('core/store'), - 'store_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE - ) - ->setComment('Poll'); -$installer->getConnection()->createTable($table); - -/** - * Create table 'poll_answer' - */ -$table = $installer->getConnection() - ->newTable($installer->getTable('poll/poll_answer')) - ->addColumn('answer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ], 'Answer Id') - ->addColumn('poll_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Poll Id') - ->addColumn('answer_title', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ - ], 'Answer title') - ->addColumn('votes_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Votes Count') - ->addColumn('answer_order', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'nullable' => false, - 'default' => '0', - ], 'Answers display') - ->addIndex( - $installer->getIdxName('poll/poll_answer', ['poll_id']), - ['poll_id'] - ) - ->addForeignKey( - $installer->getFkName('poll/poll_answer', 'poll_id', 'poll/poll', 'poll_id'), - 'poll_id', - $installer->getTable('poll/poll'), - 'poll_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE - ) - ->setComment('Poll Answers'); -$installer->getConnection()->createTable($table); - -/** - * Create table 'poll_store' - */ -$table = $installer->getConnection() - ->newTable($installer->getTable('poll/poll_store')) - ->addColumn('poll_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'unsigned' => true, - 'primary' => true, - 'nullable' => false, - 'default' => '0', - ], 'Poll Id') - ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'unsigned' => true, - 'primary' => true, - 'nullable' => false, - 'default' => '0', - ], 'Store id') - ->addIndex( - $installer->getIdxName('poll/poll_store', ['store_id']), - ['store_id'] - ) - ->addForeignKey( - $installer->getFkName('poll/poll_store', 'poll_id', 'poll/poll', 'poll_id'), - 'poll_id', - $installer->getTable('poll/poll'), - 'poll_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE - ) - ->addForeignKey( - $installer->getFkName('poll/poll_store', 'store_id', 'core/store', 'store_id'), - 'store_id', - $installer->getTable('core/store'), - 'store_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE - ) - ->setComment('Poll Store'); -$installer->getConnection()->createTable($table); - -/** - * Create table 'poll_vote' - */ -$table = $installer->getConnection() - ->newTable($installer->getTable('poll/poll_vote')) - ->addColumn('vote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ], 'Vote Id') - ->addColumn('poll_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Poll Id') - ->addColumn('poll_answer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Poll answer id') - ->addColumn('ip_address', Varien_Db_Ddl_Table::TYPE_BIGINT, null, [ - 'nullable' => true, - ], 'Poll answer id') - ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'nullable' => true, - ], 'Customer id') - ->addColumn('vote_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - 'nullable' => true, - ], 'Date closed') - ->addIndex( - $installer->getIdxName('poll/poll_vote', ['poll_answer_id']), - ['poll_answer_id'] - ) - ->addForeignKey( - $installer->getFkName('poll/poll_vote', 'poll_answer_id', 'poll/poll_answer', 'answer_id'), - 'poll_answer_id', - $installer->getTable('poll/poll_answer'), - 'answer_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE - ) - ->setComment('Poll Vote'); -$installer->getConnection()->createTable($table); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-install-0.7.0.php b/app/code/core/Mage/Poll/sql/poll_setup/mysql4-install-0.7.0.php deleted file mode 100644 index de5a88813fc..00000000000 --- a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-install-0.7.0.php +++ /dev/null @@ -1,82 +0,0 @@ -startSetup(); - -$installer->run(" - --- DROP TABLE IF EXISTS {$this->getTable('poll')}; -CREATE TABLE {$this->getTable('poll')} ( - `poll_id` int(10) unsigned NOT NULL auto_increment, - `poll_title` varchar(255) NOT NULL default '', - `votes_count` int(10) unsigned NOT NULL default '0', - `store_id` smallint(6) NOT NULL default '0', - `date_posted` datetime NOT NULL default '0000-00-00 00:00:00', - `date_closed` datetime default NULL, - `active` smallint(6) NOT NULL default '1', - `closed` tinyint(1) NOT NULL default '0', - `answers_display` smallint(6) default NULL, - PRIMARY KEY (`poll_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -insert into {$this->getTable('poll')}(`poll_id`,`poll_title`,`votes_count`,`store_id`,`date_posted`,`date_closed`,`active`,`closed`,`answers_display`) values (1,'What is your favorite color',5,1, NOW(),NULL,1,0,NULL); - --- DROP TABLE IF EXISTS {$this->getTable('poll_answer')}; -CREATE TABLE {$this->getTable('poll_answer')} ( - `answer_id` int(10) unsigned NOT NULL auto_increment, - `poll_id` int(10) unsigned NOT NULL default '0', - `answer_title` varchar(255) NOT NULL default '', - `votes_count` int(10) unsigned NOT NULL default '0', - `answer_order` smallint(6) NOT NULL default '0', - PRIMARY KEY (`answer_id`), - KEY `FK_POLL_PARENT` (`poll_id`), - CONSTRAINT `FK_POLL_PARENT` FOREIGN KEY (`poll_id`) REFERENCES {$this->getTable('poll')} (`poll_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -insert into {$this->getTable('poll_answer')}(`answer_id`,`poll_id`,`answer_title`,`votes_count`,`answer_order`) values (1,1,'Green',4,0),(2,1,'Red',1,0),(3,1,'Black',0,0),(4,1,'Magenta',0,0); - --- DROP TABLE IF EXISTS {$this->getTable('poll_store')}; -CREATE TABLE {$this->getTable('poll_store')} ( - `poll_id` int(10) unsigned NOT NULL default '0', - `store_id` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`poll_id`,`store_id`), - CONSTRAINT `FK_POLL_STORE` FOREIGN KEY (`poll_id`) REFERENCES {$this->getTable('poll')} (`poll_id`) ON DELETE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -INSERT INTO {$this->getTable('poll_store')} (`poll_id`,`store_id`) VALUES(1,1); --- DROP TABLE IF EXISTS {$this->getTable('poll_vote')}; -CREATE TABLE {$this->getTable('poll_vote')} ( - `vote_id` int(10) unsigned NOT NULL auto_increment, - `poll_id` int(10) unsigned NOT NULL default '0', - `poll_answer_id` int(10) unsigned NOT NULL default '0', - `ip_address` bigint(20) default NULL, - `customer_id` int(11) default NULL, - `vote_time` timestamp NOT NULL, - PRIMARY KEY (`vote_id`), - KEY `FK_POLL_ANSWER` (`poll_answer_id`), - CONSTRAINT `FK_POLL_ANSWER` FOREIGN KEY (`poll_answer_id`) REFERENCES {$this->getTable('poll_answer')} (`answer_id`) ON DELETE CASCADE ON UPDATE CASCADE -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - "); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-0.6.0-0.6.1.php b/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-0.6.0-0.6.1.php deleted file mode 100644 index d9b292a9174..00000000000 --- a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-0.6.0-0.6.1.php +++ /dev/null @@ -1,39 +0,0 @@ -dropForeignKey('poll_answer', 'FK_POLL_PARENT'); -$conn->dropForeignKey('poll_vote', 'FK_POLL_ANSWER'); -$this->startSetup() - ->run(" - ALTER TABLE {$this->getTable('poll')} CHANGE `poll_id` `poll_id` INT UNSIGNED NOT NULL AUTO_INCREMENT; - ALTER TABLE {$this->getTable('poll_answer')} CHANGE `poll_id` `poll_id` INT UNSIGNED NOT NULL DEFAULT '0'; - ALTER TABLE {$this->getTable('poll_answer')} CHANGE `answer_id` `answer_id` INT UNSIGNED NOT NULL AUTO_INCREMENT; - ALTER TABLE {$this->getTable('poll_vote')} CHANGE `poll_id` `poll_id` INT UNSIGNED NOT NULL DEFAULT '0'; - ALTER TABLE {$this->getTable('poll_vote')} CHANGE `poll_answer_id` `poll_answer_id` INT UNSIGNED NOT NULL DEFAULT '0'; - CREATE TABLE {$this->getTable('poll_store')} ( - `poll_id` int UNSIGNED NOT NULL, - `store_id` smallint(5) unsigned NOT NULL, - PRIMARY KEY (`poll_id`,`store_id`), - CONSTRAINT `FK_POLL_STORE` FOREIGN KEY (`poll_id`) REFERENCES {$this->getTable('poll')} (`poll_id`) ON DELETE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - ALTER TABLE `{$this->getTable('poll_answer')}` ADD CONSTRAINT `FK_POLL_PARENT` FOREIGN KEY (`poll_id`) REFERENCES {$this->getTable('poll')} (`poll_id`) ON DELETE CASCADE ON UPDATE CASCADE; - ALTER TABLE `{$this->getTable('poll_vote')}` ADD CONSTRAINT `FK_POLL_ANSWER` FOREIGN KEY (`poll_answer_id`) REFERENCES {$this->getTable('poll_answer')} (`answer_id`) ON DELETE CASCADE ON UPDATE CASCADE; -") - ->endSetup(); diff --git a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-0.7.1-0.7.2.php b/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-0.7.1-0.7.2.php deleted file mode 100644 index 2b5e9dcc5b7..00000000000 --- a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-0.7.1-0.7.2.php +++ /dev/null @@ -1,51 +0,0 @@ -startSetup(); - -$installer->run(" -ALTER TABLE {$this->getTable('poll_store')} - DROP FOREIGN KEY `FK_POLL_STORE`; -ALTER TABLE {$this->getTable('poll_store')} - ADD CONSTRAINT `FK_POLL_STORE_POLL` FOREIGN KEY (`poll_id`) - REFERENCES {$this->getTable('poll')} (`poll_id`) - ON UPDATE CASCADE - ON DELETE CASCADE; -"); -$installer->run(" -ALTER TABLE {$this->getTable('poll')} - CHANGE `store_id` `store_id` smallint(5) unsigned NULL DEFAULT '0'; -ALTER TABLE {$this->getTable('poll')} - ADD CONSTRAINT `FK_POLL_STORE` FOREIGN KEY (`store_id`) - REFERENCES {$this->getTable('core_store')} (`store_id`) - ON UPDATE CASCADE - ON DELETE SET NULL; -"); -$installer->run(" -ALTER TABLE {$this->getTable('poll_store')} - ADD CONSTRAINT `FK_POLL_STORE_STORE` FOREIGN KEY (`store_id`) - REFERENCES {$this->getTable('core_store')} (`store_id`) - ON UPDATE CASCADE - ON DELETE CASCADE; -"); -$installer->endSetup(); diff --git a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php b/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php deleted file mode 100644 index 1af34a64f5d..00000000000 --- a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php +++ /dev/null @@ -1,312 +0,0 @@ -startSetup(); - -/** - * Drop foreign keys - */ -$installer->getConnection()->dropForeignKey( - $installer->getTable('poll/poll'), - 'FK_POLL_STORE' -); - -$installer->getConnection()->dropForeignKey( - $installer->getTable('poll/poll_answer'), - 'FK_POLL_PARENT' -); - -$installer->getConnection()->dropForeignKey( - $installer->getTable('poll/poll_store'), - 'FK_POLL_STORE_POLL' -); - -$installer->getConnection()->dropForeignKey( - $installer->getTable('poll/poll_store'), - 'FK_POLL_STORE_STORE' -); - -$installer->getConnection()->dropForeignKey( - $installer->getTable('poll/poll_vote'), - 'FK_POLL_ANSWER' -); - -/** - * Drop indexes - */ -$installer->getConnection()->dropIndex( - $installer->getTable('poll/poll'), - 'FK_POLL_STORE' -); - -$installer->getConnection()->dropIndex( - $installer->getTable('poll/poll_answer'), - 'FK_POLL_PARENT' -); - -$installer->getConnection()->dropIndex( - $installer->getTable('poll/poll_store'), - 'FK_POLL_STORE_STORE' -); - -$installer->getConnection()->dropIndex( - $installer->getTable('poll/poll_vote'), - 'FK_POLL_ANSWER' -); - -/** - * Change columns - */ -$tables = [ - $installer->getTable('poll/poll') => [ - 'columns' => [ - 'poll_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'comment' => 'Poll Id' - ], - 'poll_title' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 255, - 'comment' => 'Poll title' - ], - 'votes_count' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Votes Count' - ], - 'store_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Store id' - ], - 'date_posted' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP, - 'nullable' => false, - 'comment' => 'Date posted' - ], - 'date_closed' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP, - 'nullable' => true, - 'comment' => 'Date closed' - ], - 'active' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'nullable' => false, - 'default' => '1', - 'comment' => 'Is active' - ], - 'closed' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Is closed' - ], - 'answers_display' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'comment' => 'Answers display' - ] - ], - 'comment' => 'Poll' - ], - $installer->getTable('poll/poll_answer') => [ - 'columns' => [ - 'answer_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'comment' => 'Answer Id' - ], - 'poll_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Poll Id' - ], - 'answer_title' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 255, - 'comment' => 'Answer title' - ], - 'votes_count' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Votes Count' - ], - 'answer_order' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Answers display' - ] - ], - 'comment' => 'Poll Answers' - ], - $installer->getTable('poll/poll_vote') => [ - 'columns' => [ - 'vote_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'comment' => 'Vote Id' - ], - 'poll_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Poll Id' - ], - 'poll_answer_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Poll answer id' - ], - 'ip_address' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_BIGINT, - 'comment' => 'Poll answer id' - ], - 'customer_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'comment' => 'Customer id' - ], - 'vote_time' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP, - 'nullable' => true, - 'comment' => 'Date closed' - ] - ], - 'comment' => 'Poll Vote' - ], - $installer->getTable('poll/poll_store') => [ - 'columns' => [ - 'poll_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'default' => '0', - 'comment' => 'Poll Id' - ], - 'store_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'default' => '0', - 'comment' => 'Store id' - ] - ], - 'comment' => 'Poll Store' - ] -]; - -$installer->getConnection()->modifyTables($tables); - -/** - * Add indexes - */ -$installer->getConnection()->addIndex( - $installer->getTable('poll/poll'), - $installer->getIdxName('poll/poll', ['store_id']), - ['store_id'] -); - -$installer->getConnection()->addIndex( - $installer->getTable('poll/poll_answer'), - $installer->getIdxName('poll/poll_answer', ['poll_id']), - ['poll_id'] -); - -$installer->getConnection()->addIndex( - $installer->getTable('poll/poll_store'), - $installer->getIdxName('poll/poll_store', ['store_id']), - ['store_id'] -); - -$installer->getConnection()->addIndex( - $installer->getTable('poll/poll_vote'), - $installer->getIdxName('poll/poll_vote', ['poll_answer_id']), - ['poll_answer_id'] -); - -/** - * Add foreign keys - */ -$installer->getConnection()->addForeignKey( - $installer->getFkName('poll/poll', 'store_id', 'core/store', 'store_id'), - $installer->getTable('poll/poll'), - 'store_id', - $installer->getTable('core/store'), - 'store_id' -); - -$installer->getConnection()->addForeignKey( - $installer->getFkName('poll/poll_answer', 'poll_id', 'poll/poll', 'poll_id'), - $installer->getTable('poll/poll_answer'), - 'poll_id', - $installer->getTable('poll/poll'), - 'poll_id' -); - -$installer->getConnection()->addForeignKey( - $installer->getFkName('poll/poll_store', 'poll_id', 'poll/poll', 'poll_id'), - $installer->getTable('poll/poll_store'), - 'poll_id', - $installer->getTable('poll/poll'), - 'poll_id' -); - -$installer->getConnection()->addForeignKey( - $installer->getFkName('poll/poll_store', 'store_id', 'core/store', 'store_id'), - $installer->getTable('poll/poll_store'), - 'store_id', - $installer->getTable('core/store'), - 'store_id' -); - -$installer->getConnection()->addForeignKey( - $installer->getFkName('poll/poll_vote', 'poll_answer_id', 'poll/poll_answer', 'answer_id'), - $installer->getTable('poll/poll_vote'), - 'poll_answer_id', - $installer->getTable('poll/poll_answer'), - 'answer_id' -); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php b/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php deleted file mode 100644 index 1ca37168ac8..00000000000 --- a/app/code/core/Mage/Poll/sql/poll_setup/mysql4-upgrade-1.6.0.0-1.6.0.1.php +++ /dev/null @@ -1,40 +0,0 @@ -startSetup(); - -$installer->getConnection()->changeColumn( - $installer->getTable('poll/poll_vote'), - 'ip_address', - 'ip_address', - 'varbinary(16)' -); - -$installer->getConnection()->update( - $installer->getTable('poll/poll_vote'), - [ - 'ip_address' => new Zend_Db_Expr('UNHEX(HEX(CAST(ip_address as UNSIGNED INT)))') - ] -); - -$installer->endSetup(); diff --git a/app/design/adminhtml/default/default/template/poll/answers/list.phtml b/app/design/adminhtml/default/default/template/poll/answers/list.phtml deleted file mode 100644 index 2e18bf962de..00000000000 --- a/app/design/adminhtml/default/default/template/poll/answers/list.phtml +++ /dev/null @@ -1,100 +0,0 @@ - -
- - -
-

__('Assigned Answers') ?>

-
- getItems() as $_item): ?> -
- - - - - - - - - -
-

getDeleteButtonHtml() ?>

-
- -
- - -
-

getAddButtonHtml(); ?>

- - diff --git a/app/design/frontend/base/default/layout/poll.xml b/app/design/frontend/base/default/layout/poll.xml deleted file mode 100644 index 7369fa9f917..00000000000 --- a/app/design/frontend/base/default/layout/poll.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - poll - results - - - - - - - - - - right.poll - - - - diff --git a/app/design/frontend/base/default/template/poll/active.phtml b/app/design/frontend/base/default/template/poll/active.phtml deleted file mode 100644 index 331f7f93a5f..00000000000 --- a/app/design/frontend/base/default/template/poll/active.phtml +++ /dev/null @@ -1,61 +0,0 @@ - - - -
-
- __('Community Poll') ?> -
-
-
-

escapeHtml($poll->getPollTitle()); ?>

- -
    - -
  • - - -
  • - -
- - -
- -
-
-
-
- diff --git a/app/design/frontend/base/default/template/poll/result.phtml b/app/design/frontend/base/default/template/poll/result.phtml deleted file mode 100644 index ca8af0cf5e4..00000000000 --- a/app/design/frontend/base/default/template/poll/result.phtml +++ /dev/null @@ -1,42 +0,0 @@ - - -
-
- __('Community Poll') ?> -
-
-

escapeHtml($poll->getPollTitle()); ?>

- -
    - -
  1. - getVotesCount() ?> (getPercent() ?>%) - escapeHtml($answer->getAnswerTitle()) ?>: -
  2. - -
- - -
-
- diff --git a/app/etc/modules/Mage_Poll.xml b/app/etc/modules/Mage_Poll.xml deleted file mode 100644 index 32ab81c5b27..00000000000 --- a/app/etc/modules/Mage_Poll.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - true - core - - - - - - - diff --git a/app/locale/en_US/Mage_Poll.csv b/app/locale/en_US/Mage_Poll.csv deleted file mode 100644 index 7245790a197..00000000000 --- a/app/locale/en_US/Mage_Poll.csv +++ /dev/null @@ -1,42 +0,0 @@ -"Actions","Actions" -"Add Answer","Add Answer" -"Add New Answer","Add New Answer" -"Add New Poll","Add New Poll" -"Answer Title","Answer Title" -"Answer Title:","Answer Title:" -"Answer with the same title in this poll","Answer with the same title in this poll" -"Are you sure you want to delete it?","Are you sure you want to delete it?" -"Assigned Answers","Assigned Answers" -"Closed","Closed" -"Community Poll","Community Poll" -"Date Closed","Date Closed" -"Date Posted","Date Posted" -"Delete","Delete" -"Delete Answer","Delete Answer" -"Delete Poll","Delete Poll" -"Disallow Voting in a Poll Multiple Times from Same IP-address","Disallow Voting in a Poll Multiple Times from Same IP-address" -"Edit Answer '%s'","Edit Answer '%s'" -"Edit Poll '%s'","Edit Poll '%s'" -"Edit Poll Answer","Edit Poll Answer" -"ID","ID" -"Invalid Answer.","Invalid Answer." -"New Poll","New Poll" -"Number of Responses","Number of Responses" -"Open","Open" -"Poll Answers","Poll Answers" -"Poll Information","Poll Information" -"Poll Manager","Poll Manager" -"Poll Question","Poll Question" -"Poll information","Poll information" -"Poll with the same question","Poll with the same question" -"Polls","Polls" -"Save Answer","Save Answer" -"Save Poll","Save Poll" -"Status","Status" -"The answer has been saved.","The answer has been saved." -"The poll does not exist.","The poll does not exist." -"Unable to find an answer to delete.","Unable to find an answer to delete." -"Visible In","Visible In" -"Vote","Vote" -"Votes Count","Votes Count" -"Votes Count:","Votes Count:"