function cloneSurvey($resetOriginalQuestionID = false) { $row = array('id' => null, 'title' => $this->Title, 'valid_from' => $this->ValidFrom, 'valid_to' => $this->ValidTo, 'enabled' => $this->Enabled, 'published' => $this->Published, 'one_answer' => $this->OneAnswer, 'persistent' => $this->Persistent, 'redirect_cancel' => $this->RedirectCancel, 'redirect_submit' => $this->RedirectSubmit); $cloned = new eZSurvey($row); $cloned->store(); if ($this->QuestionList === null) { $this->fetchQuestionList(); } foreach (array_keys($this->QuestionList) as $key) { $question =& $this->QuestionList[$key]; $clonedID = $cloned->attribute('id'); $question->cloneQuestion($clonedID, $resetOriginalQuestionID); } return $cloned; }
function postInitializeObjectAttribute($objectAttribute, $currentVersion, $originalContentObjectAttribute) { if (!$currentVersion) { $newSurvey = new eZSurvey(); $newSurvey->setAttribute('contentobject_id', $objectAttribute->attribute("contentobject_id")); $newSurvey->setAttribute('contentobjectattribute_id', $objectAttribute->attribute('id')); $newSurvey->setAttribute('contentobjectattribute_version', $objectAttribute->attribute("version")); $newSurvey->setAttribute('contentclassattribute_id', $objectAttribute->attribute("contentclassattribute_id")); $newSurvey->setAttribute('language_code', $objectAttribute->attribute("language_code")); $newSurvey->store(); $objectAttribute->setAttribute(self::CONTENT_VALUE, $newSurvey->attribute('id')); $objectAttribute->sync(); } else { $resetOriginalQuestionID = false; $contentObjectID = $objectAttribute->attribute('contentobject_id'); $originalContentObjectID = $originalContentObjectAttribute->attribute('contentobject_id'); $languageCode = $objectAttribute->attribute('language_code'); $originalLanguageCode = $originalContentObjectAttribute->attribute('language_code'); if ($contentObjectID != $originalContentObjectID or $languageCode != $originalLanguageCode) { $resetOriginalQuestionID = true; } $surveyID = $objectAttribute->attribute(self::CONTENT_VALUE); $survey = $this->fetchSurveyByID($surveyID, 'initializeObjectAttribute'); $clonedSurvey = $survey->cloneSurvey($resetOriginalQuestionID); $clonedSurvey->setAttribute('contentobject_id', $objectAttribute->attribute('contentobject_id')); $clonedSurvey->setAttribute('contentobjectattribute_id', $objectAttribute->attribute('id')); $clonedSurvey->setAttribute('contentobjectattribute_version', $objectAttribute->attribute("version")); $clonedSurvey->setAttribute('contentclassattribute_id', $objectAttribute->attribute("contentclassattribute_id")); $clonedSurvey->setAttribute('language_code', $objectAttribute->attribute("language_code")); $clonedSurvey->setAttribute('published', 1); $clonedSurvey->store(); $objectAttribute->setAttribute(self::CONTENT_VALUE, $clonedSurvey->attribute('id')); $objectAttribute->sync(); } }