private function upgradeDbV23() { $this->_wpdb->query(' ALTER TABLE ' . $this->_wpdb->prefix . 'wp_pro_quiz_master ADD `admin_email` TEXT NOT NULL , ADD `user_email` TEXT NOT NULL ; '); $mapper = new WpProQuiz_Model_GlobalSettingsMapper(); $adminEmail = $mapper->getEmailSettings(); $userEmail = $mapper->getUserEmailSettings(); $adminEmailNew = new WpProQuiz_Model_Email(); $adminEmailNew->setTo($adminEmail['to']); $adminEmailNew->setFrom($adminEmail['from']); $adminEmailNew->setSubject($adminEmail['subject']); $adminEmailNew->setHtml($adminEmail['html']); $adminEmailNew->setMessage($adminEmail['message']); $userEmailNew = new WpProQuiz_Model_Email(); $userEmailNew->setFrom($userEmail['from']); $userEmailNew->setToUser(true); $userEmailNew->setSubject($userEmail['subject']); $userEmailNew->setHtml($userEmail['html']); $userEmailNew->setMessage($userEmail['message']); $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master', array('admin_email' => @serialize($adminEmailNew)), array('email_notification' => 1), array('%s'), array('%d')); $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master', array('admin_email' => @serialize($adminEmailNew)), array('email_notification' => 2), array('%s'), array('%d')); $this->_wpdb->update($this->_wpdb->prefix . 'wp_pro_quiz_master', array('user_email' => @serialize($userEmailNew)), array('user_email_notification' => 1), array('%s'), array('%d')); return 24; }
private function createQuizModel($xml) { $model = new WpProQuiz_Model_Quiz(); $model->setName(trim($xml->title)); $model->setText(trim($xml->text)); $model->setTitleHidden($xml->title->attributes()->titleHidden == 'true'); $model->setQuestionRandom($xml->questionRandom == 'true'); $model->setAnswerRandom($xml->answerRandom == 'true'); $model->setTimeLimit($xml->timeLimit); $model->setResultText($xml->resultText); $model->setResultGradeEnabled($xml->resultText); $model->setCategoryName(trim($xml->category)); if (isset($xml->resultText)) { $attr = $xml->resultText->attributes(); if ($attr !== null) { $model->setResultGradeEnabled($attr->gradeEnabled == 'true'); if ($model->isResultGradeEnabled()) { $resultArray = array('text' => array(), 'prozent' => array()); foreach ($xml->resultText->text as $result) { $resultArray['text'][] = trim((string) $result); $resultArray['prozent'][] = $result->attributes() === null ? 0 : (int) $result->attributes()->prozent; } $model->setResultText($resultArray); } else { $model->setResultText(trim((string) $xml->resultText)); } } } $model->setShowPoints($xml->showPoints == 'true'); $model->setBtnRestartQuizHidden($xml->btnRestartQuizHidden == 'true'); $model->setBtnViewQuestionHidden($xml->btnViewQuestionHidden == 'true'); $model->setNumberedAnswer($xml->numberedAnswer == 'true'); $model->setHideAnswerMessageBox($xml->hideAnswerMessageBox == 'true'); $model->setDisabledAnswerMark($xml->disabledAnswerMark == 'true'); if (isset($xml->statistic)) { $attr = $xml->statistic->attributes(); if ($attr !== null) { $model->setStatisticsOn($attr->activated == 'true'); $model->setStatisticsIpLock($attr->ipLock); } } if (isset($xml->quizRunOnce)) { $model->setQuizRunOnce($xml->quizRunOnce == 'true'); $attr = $xml->quizRunOnce->attributes(); if ($attr !== null) { $model->setQuizRunOnceCookie($attr->cookie == 'true'); $model->setQuizRunOnceType($attr->type); $model->setQuizRunOnceTime($attr->time); } } if (isset($xml->showMaxQuestion)) { $model->setShowMaxQuestion($xml->showMaxQuestion == 'true'); $attr = $xml->showMaxQuestion->attributes(); if ($attr !== null) { $model->setShowMaxQuestionValue($attr->showMaxQuestionValue); $model->setShowMaxQuestionPercent($attr->showMaxQuestionPercent == 'true'); } } $model->setEndOnFirstIncorrect($xml->endOnFirstIncorrect == 'true'); if (isset($xml->toplist)) { $model->setToplistActivated($xml->toplist->attributes()->activated == 'true'); $model->setToplistDataAddPermissions($xml->toplist->toplistDataAddPermissions); $model->setToplistDataSort($xml->toplist->toplistDataSort); $model->setToplistDataAddMultiple($xml->toplist->toplistDataAddMultiple == 'true'); $model->setToplistDataAddBlock($xml->toplist->toplistDataAddBlock); $model->setToplistDataShowLimit($xml->toplist->toplistDataShowLimit); $model->setToplistDataShowIn($xml->toplist->toplistDataShowIn); $model->setToplistDataCaptcha($xml->toplist->toplistDataCaptcha == 'true'); $model->setToplistDataAddAutomatic($xml->toplist->toplistDataAddAutomatic == 'true'); } $model->setShowAverageResult($xml->showAverageResult == 'true'); $model->setPrerequisite($xml->prerequisite == 'true'); $model->setQuizModus($xml->quizModus); $model->setShowReviewQuestion($xml->showReviewQuestion == 'true'); $model->setQuizSummaryHide($xml->quizSummaryHide == 'true'); $model->setSkipQuestionDisabled($xml->skipQuestionDisabled == 'true'); $model->setEmailNotification($xml->emailNotification); $model->setUserEmailNotification($xml->userEmailNotification == 'true'); $model->setShowCategoryScore($xml->showCategoryScore == 'true'); $model->setHideResultCorrectQuestion($xml->hideResultCorrectQuestion == 'true'); $model->setHideResultQuizTime($xml->hideResultQuizTime == 'true'); $model->setHideResultPoints($xml->hideResultPoints == 'true'); $model->setAutostart($xml->autostart == 'true'); $model->setForcingQuestionSolve($xml->forcingQuestionSolve == 'true'); $model->setHideQuestionPositionOverview($xml->hideQuestionPositionOverview == 'true'); $model->setHideQuestionNumbering($xml->hideQuestionNumbering == 'true'); //0.27 $model->setStartOnlyRegisteredUser($xml->startOnlyRegisteredUser == 'true'); $model->setSortCategories($xml->sortCategories == 'true'); $model->setShowCategory($xml->showCategory == 'true'); if (isset($xml->quizModus)) { $attr = $xml->quizModus->attributes(); if ($attr !== null) { $model->setQuestionsPerPage($attr->questionsPerPage); } } if (isset($xml->forms)) { $attr = $xml->forms->attributes(); $model->setFormActivated($attr->activated == 'true'); $model->setFormShowPosition($attr->position); } //0.29 if (isset($xml->adminEmail)) { $adminEmail = new WpProQuiz_Model_Email(); $adminEmail->setTo($xml->adminEmail->to); $adminEmail->setFrom($xml->adminEmail->form); $adminEmail->setSubject($xml->adminEmail->subject); $adminEmail->setHtml($xml->adminEmail->html == 'true'); $adminEmail->setMessage($xml->adminEmail->message); $model->setAdminEmail($adminEmail); } if (isset($xml->userEmail)) { $userEmail = new WpProQuiz_Model_Email(); $userEmail->setTo($xml->userEmail->to); $userEmail->setToUser($xml->userEmail->toUser == 'true'); $userEmail->setToForm($xml->userEmail->toForm == 'true'); $userEmail->setFrom($xml->userEmail->form); $userEmail->setSubject($xml->userEmail->subject); $userEmail->setHtml($xml->userEmail->html == 'true'); $userEmail->setMessage($xml->userEmail->message); $model->setUserEmail($userEmail); } //Check if ($model->getName() == '') { return null; } if ($model->getText() == '') { return null; } return $model; }