Пример #1
0
 function poll($aData)
 {
     $voteid = isset($aData['poll']) ? $aData['poll'] : '';
     $id = $aData['id'] ? $aData['id'] : '';
     $tblPolliP = new App_Model_Db_Table_PollIp();
     $ip_result = $tblPolliP->fetchRow("ip='" . Pandamp_Lib_Formater::getRealIpAddr() . "' AND pollGuid='" . $id . "'");
     if (!isset($ip_result)) {
         $rowIp = $tblPolliP->fetchNew();
         $rowIp->dateOfPoll = date("Y-m-d H:i:s");
         $rowIp->ip = Pandamp_Lib_Formater::getRealIpAddr();
         $rowIp->voteId = $voteid;
         $rowIp->pollGuid = $id;
         $rowIp->save();
         if ($voteid) {
             $tblPoll = new App_Model_Db_Table_Poll();
             $rowPoll = $tblPoll->find($id)->current();
             if ($rowPoll) {
                 $rowPoll->voters = $rowPoll->voters + 1;
                 $rowPoll->save();
             }
             $tblOption = new App_Model_Db_Table_PollOption();
             $rowOption = $tblOption->fetchRow("guid='{$voteid}' AND pollGuid='{$id}'");
             if ($rowOption) {
                 $rowOption->hits = $rowOption->hits + 1;
                 $rowOption->save();
             }
         }
     }
 }
Пример #2
0
 function whosAction()
 {
     $pollId = $this->_getParam('id') ? $this->_getParam('id') : '';
     $tblPolling = new App_Model_Db_Table_Poll();
     $time = time();
     $date = date("Y-m-d H:i:s", $time);
     $rowPoll = $tblPolling->fetchRow("guid='{$pollId}' AND checkedTime < '{$date}'", "checkedTime DESC");
     $this->view->rowPoll = $rowPoll;
     $this->view->pollId = $pollId;
     $this->_helper->layout()->headerTitle = "Polling";
 }
Пример #3
0
 function pollAction()
 {
     $this->_helper->layout->setLayout('layout-polling');
     $pollId = $this->_getParam('guid') ? $this->_getParam('guid') : '';
     $tblPolling = new App_Model_Db_Table_Poll();
     $time = time();
     $date = date("Y-m-d H:i:s", $time);
     $rowPoll = $tblPolling->fetchAll("guid NOT IN('{$pollId}') AND checkedTime < '{$date}'", "checkedTime DESC");
     $this->view->rowPoll = $rowPoll;
     $this->view->pollId = $pollId;
 }
Пример #4
0
 public function deleteAction()
 {
     $this->_helper->getHelper('layout')->disableLayout();
     $this->_helper->getHelper('viewRenderer')->setNoRender();
     $this->preProcessSession();
     $request = $this->getRequest();
     $result = 'RESULT_ERROR';
     if ($request->isPost()) {
         $guid = $request->getPost('guid');
         $ids = array();
         $ids = Zend_Json::decode($guid);
         $pollingDb = new App_Model_Db_Table_Poll();
         $pollingOptionDb = new App_Model_Db_Table_PollOption();
         foreach ($ids as $pollId) {
             $pollingDb->delete(['guid=?' => $pollId]);
             $pollingOptionDb->delete(['pollGuid=?' => $pollId]);
         }
         $result = 'RESULT_OK';
     }
     $this->getResponse()->setBody($result);
 }