Beispiel #1
0
 function result()
 {
     $surveyID = $this->attribute('survey_id');
     $survey = eZSurvey::fetch($surveyID);
     $contentObjectID = $survey->attribute('contentobject_id');
     $contentClassAttributeID = $survey->attribute('contentclassattribute_id');
     $languageCode = $survey->attribute('language_code');
     $result = eZSurveyEntry::fetchResult($this, $contentObjectID, $contentClassAttributeID, $languageCode, false, 5);
     return $result['result'];
 }
 function eZSurveyRelatedObject($row = false)
 {
     $row['type'] = 'RelatedObject';
     $this->eZSurveyQuestion($row);
     $surveyID = $this->attribute('survey_id');
     $survey = eZSurvey::fetch($surveyID);
     $contentObjectID = $survey->attribute('contentobject_id');
     $postRelatedObject = 'SelectedNodeIDArray';
     $http = eZHTTPTool::instance();
     if ($http->hasPostVariable($postRelatedObject)) {
         // need to do an extra check if this is the datatype that should receive the information.
         $value = $http->postVariable($postRelatedObject);
     }
     $http = eZHTTPTool::instance();
     $module = $GLOBALS['module'];
     //         $http->removeSessionVariable( 'LastAccessesURI' );
     //         $http->removeSessionVariable( 'RedirectURIAfterPublish' );
     //         $http->removeSessionVariable( 'RedirectIfDiscarded' );
     if ($module->exitStatus() !== eZModule::STATUS_REDIRECT) {
         if ($http->hasSessionVariable('LastAccessesURI_Backup_' . $contentObjectID . '_' . $this->ID) and $http->sessionVariable('LastAccessesURI_Backup_' . $contentObjectID . '_' . $this->ID) !== null) {
             $value = $http->sessionVariable('LastAccessesURI_Backup_' . $contentObjectID . '_' . $this->ID);
             $http->setSessionVariable('LastAccessesURI', $value['content']);
             $http->removeSessionVariable('LastAccessesURI_Backup_' . $contentObjectID . '_' . $this->ID);
             if (is_numeric($this->Num) and $this->Num > 0) {
                 $contentObjectExists = eZContentObject::exists($this->Num);
                 if ($contentObjectExists !== true) {
                     $this->Num = 0;
                     $this->store();
                 }
             }
         }
         if ($http->hasSessionVariable('RedirectURIAfterPublish_Backup_' . $contentObjectID . '_' . $this->ID) and $http->sessionVariable('RedirectURIAfterPublish_Backup_' . $contentObjectID . '_' . $this->ID) !== null) {
             $value = $http->sessionVariable('RedirectURIAfterPublish_Backup_' . $contentObjectID . '_' . $this->ID);
             $http->setSessionVariable('RedirectURIAfterPublish', $value['content']);
             $http->removeSessionVariable('RedirectURIAfterPublish_Backup_' . $contentObjectID . '_' . $this->ID);
         }
         if ($http->hasSessionVariable('RedirectIfDiscarded_Backup_' . $contentObjectID . '_' . $this->ID) and $http->sessionVariable('RedirectIfDiscarded_Backup_' . $contentObjectID . '_' . $this->ID) !== null) {
             $value = $http->sessionVariable('RedirectIfDiscarded_Backup_' . $contentObjectID . '_' . $this->ID);
             $http->setSessionVariable('RedirectIfDiscarded', $value['content']);
             $http->removeSessionVariable('RedirectIfDiscarded_Backup_' . $contentObjectID . '_' . $this->ID);
         }
     }
 }
Beispiel #3
0
 private function addSenderEmailsFromQuestions(&$emailList)
 {
     if (($survey = $this->survey($this->SurveyID)) === false) {
         $survey = eZSurvey::fetch($this->SurveyID);
     }
     if ($survey instanceof eZSurvey) {
         $questionList = $survey->fetchQuestionList();
         foreach ($questionList as $question) {
             $id = $question->attribute('original_id');
             $key = $this->questionKeyValue($question);
             switch ($question->attribute('type')) {
                 case 'EmailEntry':
                     $value = $question->attribute('text');
                     $emailList[$key] = "{$value} ({$id})";
                     break;
             }
         }
     }
 }
 private function fetchFeedbackSurvey()
 {
     if (($survey = $this->survey($this->SurveyID)) === false) {
         $survey = eZSurvey::fetch($this->SurveyID);
     }
     return $survey;
 }
Beispiel #5
0
// THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE.
//
// The "eZ Publish professional licence" is available at
// http://ez.no/products/licences/professional/. For pricing of this licence
// please contact us via e-mail to licence@ez.no. Further contact
// information is available at http://ez.no/home/contact/.
//
// The "GNU General Public License" (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.
//
// Contact licence@ez.no if any conditions of this licencing isn't clear to
// you.
//
/*! \file preview.php
*/
$http = eZHTTPTool::instance();
$Module = $Params['Module'];
$surveyID = $Params['SurveyID'];
$survey = eZSurvey::fetch($surveyID);
if (!$survey) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$res = eZTemplateDesignResource::instance();
$res->setKeys(array(array('survey', $surveyID)));
$tpl = eZTemplate::factory();
$tpl->setVariable('preview', true);
$tpl->setVariable('survey', $survey);
$Result = array();
$Result['content'] = $tpl->fetch('design:survey/view.tpl');
$Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('survey', 'Survey Preview')));
Beispiel #6
0
 function fetchSurveyByID($surveyID, $functionName = 'fetchSurveyByID')
 {
     $survey = false;
     if (is_numeric($surveyID) and $surveyID > 0) {
         $survey = eZSurvey::fetch($surveyID);
         if (!is_object($survey)) {
             eZDebug::writeWarning("Survey is not valid: " . var_export($survey, true), 'eZSurveyType::' . $functionName);
         }
     } else {
         eZDebug::writeWarning("Survey id is not numeric or above 0: " . var_export($surveyID, true), 'eZSurveyType::' . $functionName);
     }
     return $survey;
 }
Beispiel #7
0
 public static function setGlobalSurveyContent($content)
 {
     if (isset(self::$surveyContent)) {
         self::$surveyContent = $content + self::$surveyContent;
     } else {
         self::$surveyContent = $content;
     }
     return self::$surveyContent;
 }
Beispiel #8
0
// Contact licence@ez.no if any conditions of this licencing isn't clear to
// you.
//
/*! \file list.php
 */
$http = eZHTTPTool::instance();
$Module = $Params['Module'];
$surveyWizard = eZSurveyWizard::instance();
if ($surveyWizard->state() != 'none') {
    $uri = 'survey/wizard';
    $Module->redirectTo($uri);
} else {
    $offset = $Params['Offset'];
    if (!$offset) {
        $offset = 0;
    }
    $limit = 25;
    $params = array('offset' => $offset, 'limit' => $limit);
    $count = 0;
    $surveyList = eZSurvey::fetchSurveyList($params, $count);
    $viewParameters = array('offset' => $offset);
    $tpl = eZTemplate::factory();
    $tpl->setVariable('survey_list', $surveyList);
    $tpl->setVariable('count', $count);
    $tpl->setVariable('limit', $limit);
    $tpl->setVariable('view_parameters', $viewParameters);
    $Result = array();
    $Result['left_menu'] = 'design:parts/survey/menu.tpl';
    $Result['content'] = $tpl->fetch('design:survey/list.tpl');
    $Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('survey', 'Survey')));
}
Beispiel #9
0
 static function exportCSV($contentObjectID, $contentClassAttributeID, $languageCode)
 {
     $surveyString = '';
     function printLine($list, $array)
     {
         $surveyString = '';
         $found = false;
         foreach ($list as $key) {
             $login = '';
             $name = '';
             if (isset($array[$key]) and $key == 'user_id' and is_numeric($array[$key])) {
                 $userID = $array[$key];
                 $contentObject = eZContentObject::fetch($userID);
                 if ($contentObject instanceof eZContentObject) {
                     $name = $contentObject->attribute('name');
                     $dataMap = $contentObject->attribute('data_map');
                     foreach ($dataMap as $contentObjectAttribute) {
                         if ($contentObjectAttribute->attribute('data_type_string') == 'ezuser') {
                             $user = $contentObjectAttribute->content();
                             if ($user instanceof eZUser) {
                                 $content = $user->attribute('login');
                             }
                         }
                     }
                     if ($name != '') {
                         $content .= " ({$name})";
                     }
                 }
                 $surveyString .= '"' . str_replace('"', '""', $content) . '";';
             } else {
                 if (isset($array[$key])) {
                     $surveyString .= '"' . str_replace('"', '""', $array[$key]) . '";';
                     $found = true;
                 } else {
                     $surveyString .= '"";';
                 }
             }
         }
         if ($found === true) {
             $surveyString .= "\n";
         }
         return $surveyString;
     }
     $survey = eZSurvey::fetchByObjectInfo($contentObjectID, $contentClassAttributeID, $languageCode);
     if (!$survey || !$survey->published()) {
         return false;
     }
     $questionList = $survey->fetchQuestionList();
     $questions = array();
     $indexList = array();
     foreach (array_keys($questionList) as $key) {
         if ($questionList[$key]->canAnswer()) {
             $oldKey = $questionList[$key]->attribute('original_id');
             $indexList[] = $oldKey;
             $questions[$oldKey] = $questionList[$key]->attribute('text');
         }
     }
     $surveyINI = eZINI::instance('ezsurvey.ini');
     $showHeadlineUserName = $surveyINI->variable('CSVExportSettings', 'ShowUserName') == 'true' ? true : false;
     if ($showHeadlineUserName === true) {
         $indexList[] = 'user_id';
         $questions['user_id'] = $surveyINI->variable('CSVExportSettings', 'HeadlineUserName');
     }
     $surveyString = printLine($indexList, $questions);
     $db = eZDB::instance();
     $query = "SELECT ezsurveyquestionresult.result_id as result_id, question_id, questionoriginal_id, text, ezsurveyresult.user_id as user_id\n                                  FROM ezsurveyquestionresult, ezsurveyresult, ezsurvey\n                                  WHERE ezsurveyresult.id=ezsurveyquestionresult.result_id AND\n                                        ezsurveyresult.survey_id=ezsurvey.id AND\n                                        contentclassattribute_id='" . $contentClassAttributeID . "' AND\n                                        contentobject_id='" . $contentObjectID . "' AND\n                                        language_code='" . $languageCode . "'\n                                  ORDER BY tstamp ASC, ezsurveyquestionresult.result_id ASC";
     $rows = $db->arrayQuery($query);
     $extraQuery = "SELECT ezsurveyquestionmetadata.result_id as result_id, question_id, value\n                                  FROM ezsurveyquestionmetadata, ezsurveyresult, ezsurvey\n                                  WHERE ezsurveyresult.id=ezsurveyquestionmetadata.result_id AND\n                                        ezsurveyresult.survey_id=ezsurvey.id AND\n                                        ezsurveyquestionmetadata.value<>'' AND\n                                        contentclassattribute_id='" . $contentClassAttributeID . "' AND\n                                        contentobject_id='" . $contentObjectID . "' AND\n                                        language_code='" . $languageCode . "'\n                                  ORDER BY tstamp ASC, ezsurveyquestionmetadata.result_id ASC";
     $extraResultArray = $db->arrayQuery($extraQuery);
     $extraResultHash = array();
     foreach ($extraResultArray as $extraResultItem) {
         $extraResultHash[$extraResultItem['result_id']][$extraResultItem['question_id']] = $extraResultItem['value'];
     }
     $oldID = false;
     $answers = array();
     foreach (array_keys($rows) as $key) {
         $row =& $rows[$key];
         if ($oldID != $row['result_id']) {
             if ($oldID !== false) {
                 $surveyString .= printLine($indexList, $answers);
                 unset($answers);
                 $answers = array();
             }
             $oldID = $row['result_id'];
         }
         if (isset($answers[$row['questionoriginal_id']])) {
             $answers[$row['questionoriginal_id']] .= "; " . $row['text'];
         } else {
             $answers[$row['questionoriginal_id']] = $row['text'];
         }
         if (isset($extraResultHash[$row['result_id']][$row['question_id']])) {
             $answers[$row['questionoriginal_id']] .= "; " . $extraResultHash[$row['result_id']][$row['question_id']];
             unset($extraResultHash[$row['result_id']][$row['question_id']]);
         }
         if (!isset($answers['user_id']) and $showHeadlineUserName === true) {
             $answers['user_id'] = $row['user_id'];
         }
     }
     if ($oldID !== false) {
         $surveyString .= printLine($indexList, $answers);
     }
     return $surveyString;
 }
Beispiel #10
0
// please contact us via e-mail to licence@ez.no. Further contact
// information is available at http://ez.no/home/contact/.
//
// The "GNU General Public License" (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.
//
// Contact licence@ez.no if any conditions of this licencing isn't clear to
// you.
//
/*! \file export.php
*/
$Module = $Params['Module'];
$contentObjectID = $Params['ContentObjectID'];
$contentClassAttributeID = $Params['ContentClassAttributeID'];
$languageCode = $Params['LanguageCode'];
$survey = eZSurvey::fetchByObjectInfo($contentObjectID, $contentClassAttributeID, $languageCode);
if (!is_object($survey)) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// $surveyID = $survey->attribute( 'id' );
// $db = eZDB::instance();
// $db->setIsSQLOutputEnabled( false );
// $http = eZHTTPTool::instance();
$output = eZSurveyResult::exportCSV($contentObjectID, $contentClassAttributeID, $languageCode);
if ($output !== false) {
    $contentLength = strlen($output);
    header("Pragma: ");
    header("Cache-Control: ");
    header("Content-Length: {$contentLength}");
    // header( "Content-Type: application/vnd.ms-excel" );
    header("Content-Type: text/comma-separated-values");
Beispiel #11
0
 protected function surveyContentObject($surveyID)
 {
     if (!isset(self::$contentObject[$surveyID])) {
         $survey = eZSurvey::fetch($this->SurveyID);
         $survey = $this->survey();
         if ($survey instanceof eZSurvey and $object = eZContentObject::fetch($survey->attribute('contentobject_id')) and $object instanceof eZContentObject) {
             self::$contentObject[$surveyID] = $object;
         } else {
             return false;
         }
     }
     return self::$contentObject[$surveyID];
 }
Beispiel #12
0
// The "GNU General Public License" (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.
//
// Contact licence@ez.no if any conditions of this licencing isn't clear to
// you.
//
/*! \file result_list.php
*/
$http = eZHTTPTool::instance();
$Module = $Params['Module'];
$resultID = $Params['ResultID'];
$surveyResult = eZSurveyResult::fetch($resultID);
if (!$surveyResult) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$survey = eZSurvey::fetch($surveyResult->attribute('survey_id'));
if (!$survey) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
$validation = array();
$contentObjectID = $survey->attribute('contentobject_id');
$contentObjectAttributeID = $survey->attribute('contentobjectattribute_id');
$contentClassAttributeID = $survey->attribute('contentclassattribute_id');
$languageCode = $survey->attribute('language_code');
$params = array('prefix_attribute' => eZSurveyType::PREFIX_ATTRIBUTE, 'contentobjectattribute_id' => $contentObjectAttributeID);
$survey->processViewActions($validation, $params);
if ($http->hasPostVariable('SurveyStoreButton') && $validation['error'] == false) {
    $result = eZSurveyResult::instance($surveyResult->attribute('survey_id'), $surveyResult->attribute('user_id'));
    $result->storeResult($params);
    $Module->redirectTo('/survey/result_list/' . $contentObjectID . '/' . $contentClassAttributeID . '/' . $languageCode);
} else {