function store($fieldFilters = null)
 {
     if ($this->QuestionOriginalID == 0) {
         $db = eZDB::instance();
         $id = $this->QuestionID;
         $question = eZSurveyQuestion::fetch($id);
         if (get_class($question) == 'eZSurveyQuestion') {
             $this->QuestionOriginalID = $question->attribute('original_id');
         }
     }
     parent::store($fieldFilters);
 }
            $tpl_email = eZTemplate::factory();
            $tpl_email->setVariable('intro', $this->Text2);
            $tpl_email->setVariable('survey', $survey);
            $tpl_email->setVariable('survey_questions', $surveyQuestions);
            $tpl_email->setVariable('survey_node', $node);
            $templateResult = $tpl_email->fetch('design:survey/feedbackfield_mail.tpl');
            if (trim($this->Text3) != '') {
                $subject = $this->Text3;
            } else {
                $subject = $tpl_email->variable('subject');
            }
            $mail = new eZMail();
            $ini = eZINI::instance();
            $emailSender = $ini->variable('MailSettings', 'EmailSender');
            if (!$emailSender) {
                $emailSender = $ini->variable('MailSettings', 'AdminEmail');
            }
            $mail->setSenderText($emailSender);
            $mail->setReceiver($mailTo);
            $mail->setSubject($subject);
            $mail->setBody($templateResult);
            if ($this->Num == 1) {
                $adminReceiver = $ini->variable('MailSettings', 'AdminEmail');
                $mail->addBcc($adminReceiver);
            }
            $mailResult = eZMailTransport::send($mail);
        }
    }
}
eZSurveyQuestion::registerQuestionType(ezpI18n::tr('survey', 'Feedback field'), 'FeedbackField');
            $dataMap = $user->attribute('contentobject')->attribute('data_map');
            if (isset($dataMap[$identifier])) {
                $value = $dataMap[$identifier]->attribute('content');
            }
        }
        return $value;
    }
    private function userName()
    {
        $value = false;
        $user = eZUser::currentUser();
        if (get_class($user) == 'eZUser' and $user->isLoggedIn() === true) {
            $contentObject = $user->attribute('contentobject');
            if (get_class($contentObject) == 'eZContentObject') {
                $value = $contentObject->attribute('name');
            }
        }
        return $value;
    }
    private function userEmail()
    {
        $value = false;
        $user = eZUser::currentUser();
        if (get_class($user) == 'eZUser' and $user->isLoggedIn() === true) {
            $value = $user->attribute('email');
        }
        return $value;
    }
}
eZSurveyQuestion::registerQuestionType(ezpI18n::tr('survey', 'Text Entry'), 'TextEntry');
Example #4
0
 function &questionTypes()
 {
     $list = eZSurveyQuestion::listQuestionTypes();
     foreach (array_keys($list) as $index) {
         if ($list[$index]['max_one_instance'] == true) {
             if ($list[$index]['count'] > 0) {
                 unset($list[$index]);
             }
         }
     }
     uasort($list, array($this, 'sortQuestionTypeCallback'));
     return $list;
 }
Example #5
0
 function answer()
 {
     if (count($this->Options) > 1) {
         return parent::answer();
     }
     $arrayKeys = array_keys($this->Options);
     return $this->Options[$arrayKeys[0]]['value'];
 }
 function storeResult($resultID, $params)
 {
     parent::storeResult($resultID, $params);
     $answerArray = $this->extraInfoAnswer($params);
     if (count($answerArray) > 0) {
         foreach ($answerArray as $value => $content) {
             $questionMetaData = eZSurveyQuestionMetaData::instance($resultID, $this->ID, $this->OriginalID, $value, $content);
         }
     } else {
         $questionMetaData = eZSurveyQuestionMetaData::instance($resultID, $this->ID, $this->OriginalID, '', '');
     }
     $questionMetaData->store();
 }
            $filePath = '';
            $fileSize = 0;
            $fileLabel = '';
            if (array_key_exists('info', $result)) {
                $fileName = $result['info']['basename'];
                $fileLabel = $result['label'];
                //normal or unique name
                $filePath = $this->uploadPath . $fileName;
                $surveyAnswer = $filePath;
            }
            if (array_key_exists('size', $result)) {
                $fileSize = $result['size'];
            }
            //Set file specific params
            $this->setAttribute('text2', $fileLabel);
            $this->setAttribute('num2', $fileSize);
            //set to value or zero
            $this->setAnswer($surveyAnswer);
            return $surveyAnswer;
        }
        //option 3) check for answer post
        $postSurveyAnswer = $prefix . '_ezsurvey_answer_' . $this->ID . '_' . $this->contentObjectAttributeID();
        if ($http->hasPostVariable($postSurveyAnswer) && strlen($http->postVariable($postSurveyAnswer))) {
            $surveyAnswer = $http->postVariable($postSurveyAnswer);
            return $surveyAnswer;
        }
        return $this->Default;
    }
}
eZSurveyQuestion::registerQuestionType(ezpI18n::tr('survey', 'File'), 'File');
    /*!
        This is a related object and should not require an answer.
        \return false
      */
    function canAnswer()
    {
        return false;
    }
    /*!
        Iterate the number of the question. Since the related object do not have any input fields,
        The iterator should not be runned.
      */
    function questionNumberIterate(&$iterator)
    {
    }
    function &cloneQuestion($surveyID, $resetOriginalID = false)
    {
        $num = $resetOriginalID === false ? $this->Num : 0;
        $row = array('id' => null, 'survey_id' => $surveyID, 'original_id' => $this->OriginalID, 'tab_order' => $this->TabOrder, 'type' => $this->Type, 'mandatory' => $this->Mandatory, 'default_value' => $this->Default, 'text' => $this->Text, 'text2' => $this->Text2, 'text3' => $this->Text3, 'num' => $num, 'num2' => $this->Num2);
        $classname = implode('', array('eZSurvey', $this->Type));
        $cloned = new $classname($row);
        $cloned->store();
        if ($resetOriginalID === true) {
            $cloned->setAttribute('original_id', $cloned->attribute('id'));
            $cloned->store();
        }
        return $cloned;
    }
}
eZSurveyQuestion::registerQuestionType(ezpI18n::tr('survey', 'Related object'), 'RelatedObject');
//
// 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 ezsurveyparagraph.php
*/
class eZSurveyParagraph extends eZSurveyQuestion
{
    function eZSurveyParagraph($row = false)
    {
        $row['type'] = 'Paragraph';
        $this->eZSurveyQuestion($row);
    }
    function canAnswer()
    {
        return false;
    }
    function questionNumberIterate(&$iterator)
    {
    }
}
eZSurveyQuestion::registerQuestionType(ezpI18n::tr('survey', 'Paragraph'), 'Paragraph');
 static function definition()
 {
     return array_merge_recursive(array('function_attributes' => array('content' => 'xmlOutput')), eZSurveyQuestion::definition());
 }
// Contact licence@ez.no if any conditions of this licencing isn't clear to
// you.
//
/*! \file ezsurveysectionheader.php
*/
class eZSurveySectionHeader extends eZSurveyQuestion
{
    /*!
        Constructor of the survey.
      */
    function eZSurveySectionHeader($row = false)
    {
        $row['type'] = 'SectionHeader';
        $this->eZSurveyQuestion($row);
    }
    /*!
        This is a section and should not require an answer.
      */
    function canAnswer()
    {
        return false;
    }
    /*!
        Iterate the number of the question.
      */
    function questionNumberIterate(&$iterator)
    {
    }
}
eZSurveyQuestion::registerQuestionType(ezpI18n::tr('survey', 'Section Header'), 'SectionHeader');
Example #12
0
 protected function currentUserObject()
 {
     if (!isset(self::$currentUserObject)) {
         self::$currentUserObject = false;
         $user = eZUser::instance();
         if ($user instanceof eZUser) {
             $object = $user->attribute('contentobject');
             if ($object instanceof eZContentObject) {
                 self::$currentUserObject = $object;
             }
         }
     }
     return self::$currentUserObject;
 }