Пример #1
0
 /**
  * Action for creating a new instance from an existing questionnaire
  */
 public function newInstanceAction()
 {
     $session = new Zend_Session_Namespace('login');
     $instanceID = $session->newInstanceResponsesInstanceID;
     $instanceName = $this->_getParam('instanceName');
     $importResponses = $this->_getParam('newInstanceImportResponsesRadioButton');
     if (is_numeric($instanceID)) {
         $session->newInstanceResponsesInstanceID = intVal($instanceID);
     } elseif (isset($importResponses) && $importResponses === 'newInstanceImportInstanceResponses') {
         $this->_redirector->gotoRouteAndExit(array('action' => 'index'));
     }
     $questionnaire = new QuestionnaireModel(array('questionnaireID' => $session->dataQuestionnaireID, 'depth' => 'questionnaire'));
     if ($importResponses === 'newInstanceImportInstanceResponses') {
         $importResponsesInstanceID = $this->_getParam('newInstanceResponsesInstanceSelect');
         InstanceModel::importXML($questionnaire->fetchQuestionnaireDefinition(), $instanceName, array('instanceID' => $importResponsesInstanceID));
     } else {
         InstanceModel::importXML($questionnaire->fetchQuestionnaireDefinition(), $instanceName);
     }
     $this->flash('notice', 'New Instance Created');
     $this->_redirector->gotoRoute(array('action' => 'index'));
 }
 /**
  * Export actions
  */
 public function QuestionnaireDefinitionXMLDownloadAction()
 {
     $session = new Zend_Session_Namespace('login');
     $questionnaire = new QuestionnaireModel(array('questionnaireID' => $session->dataQuestionnaireID, 'depth' => 'questionnaire'));
     $cryptoID = $this->_hasParam('cryptoID') ? $this->_getParam('cryptoID') : null;
     if (isset($cryptoID) && $cryptoID != 0) {
         $crypto = new CryptoModel(array('cryptoID' => $cryptoID));
         $this->view->xml = $crypto->encrypt($questionnaire->fetchQuestionnaireDefinition());
         $this->view->cryptoID = $cryptoID;
     } else {
         $this->view->xml = $questionnaire->fetchQuestionnaireDefinition();
     }
     $this->view->setRenderLayout(false);
 }