public function deleteAction()
 {
     SxCms_Acl::requireAcl('survey', 'survey.delete');
     $surveyId = $this->_getParam('id');
     $proxy = new SxCms_Survey_DataMapper();
     $this->_survey = $proxy->getSurveyById($surveyId);
     $this->_survey->delete();
     $flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $flashMessenger->addMessage('Enquête werd succesvol verwijderd!');
     $this->_helper->redirector->gotoSimple('index', 'survey');
 }
示例#2
0
 /**
  * Save survey on datastorage
  * 
  * @return void
  */
 public function save()
 {
     $db = Zend_Registry::get('db');
     $config = Zend_Registry::get('config');
     $surveyData = array('language' => $this->getLanguage(), 'title' => $this->getTitle(), 'description' => $this->getDescription(), 'date_published' => $this->getDatePublished('%Y-%m-%d') . ' ' . $this->getTimePublished('%H:%M:%S'), 'date_expired' => $this->getDateExpired('%Y-%m-%d') . ' ' . $this->getTimeExpired('%H:%M:%S'), 'date_created' => $this->getDateCreated(), 'author_id' => $this->getAuthor());
     $survey_id = $this->getId() ? $this->getId() : SxCms_Survey_DataMapper::getMaxId();
     if ($this->getId() === false) {
         foreach ($config->system->language as $lng => $slng) {
             $surveyData['survey_id'] = $survey_id;
             $surveyData['language'] = $lng;
             $db->insert('Survey', $surveyData);
         }
     } else {
         $db->update('Survey', $surveyData, 'survey_id = ' . $survey_id . ' AND language = \'' . $this->getLanguage() . '\'');
     }
     if ($this->getId()) {
         $tmpSurvey = SxCms_Survey_DataMapper::getSurveyById($survey_id);
         foreach ($tmpSurvey->getQuestion() as $question) {
             $question->delete();
         }
     }
     if ($this->getId() === false) {
         $lngs = $config->system->language;
     } else {
         $lngs[$this->getLanguage()] = null;
     }
     // create translations
     foreach ($lngs as $lng => $slng) {
         foreach ($this->getQuestion() as $question) {
             $question->setSurveyId($survey_id);
             $question->setLanguage($lng);
             $question->save();
         }
     }
 }