private function edit() { if (!current_user_can('wpProQuiz_change_settings')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $mapper = new WpProQuiz_Model_GlobalSettingsMapper(); $categoryMapper = new WpProQuiz_Model_CategoryMapper(); $templateMapper = new WpProQuiz_Model_TemplateMapper(); $view = new WpProQuiz_View_GobalSettings(); if (isset($this->_post['submit'])) { $mapper->save(new WpProQuiz_Model_GlobalSettings($this->_post)); WpProQuiz_View_View::admin_notices(__('Settings saved', 'wp-pro-quiz'), 'info'); $toplistDateFormat = $this->_post['toplist_date_format']; if ($toplistDateFormat == 'custom') { $toplistDateFormat = trim($this->_post['toplist_date_format_custom']); } $statisticTimeFormat = $this->_post['statisticTimeFormat']; if (add_option('wpProQuiz_toplistDataFormat', $toplistDateFormat) === false) { update_option('wpProQuiz_toplistDataFormat', $toplistDateFormat); } if (add_option('wpProQuiz_statisticTimeFormat', $statisticTimeFormat, '', 'no') === false) { update_option('wpProQuiz_statisticTimeFormat', $statisticTimeFormat); } //Email //$mapper->saveEmailSettiongs($this->_post['email']); //$mapper->saveUserEmailSettiongs($this->_post['userEmail']); } else { if (isset($this->_post['databaseFix'])) { WpProQuiz_View_View::admin_notices(__('Database repaired', 'wp-pro-quiz'), 'info'); $DbUpgradeHelper = new WpProQuiz_Helper_DbUpgrade(); $DbUpgradeHelper->databaseDelta(); } } $view->settings = $mapper->fetchAll(); $view->isRaw = !preg_match('[raw]', apply_filters('the_content', '[raw]a[/raw]')); $view->category = $categoryMapper->fetchAll(); $view->categoryQuiz = $categoryMapper->fetchAll(WpProQuiz_Model_Category::CATEGORY_TYPE_QUIZ); $view->email = $mapper->getEmailSettings(); $view->userEmail = $mapper->getUserEmailSettings(); $view->templateQuiz = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUIZ, false); $view->templateQuestion = $templateMapper->fetchAll(WpProQuiz_Model_Template::TEMPLATE_TYPE_QUESTION, false); $view->toplistDataFormat = get_option('wpProQuiz_toplistDataFormat', 'Y/m/d g:i A'); $view->statisticTimeFormat = get_option('wpProQuiz_statisticTimeFormat', 'Y/m/d g:i A'); $view->show(); }
public function copyQuestion($quizId) { if (!current_user_can('wpProQuiz_edit_quiz')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $m = new WpProQuiz_Model_QuestionMapper(); $questions = $m->fetchById($this->_post['copyIds']); foreach ($questions as $question) { $question->setId(0); $question->setQuizId($quizId); $m->save($question); } WpProQuiz_View_View::admin_notices(__('questions copied', 'wp-pro-quiz'), 'info'); $this->showAction(); }
/** * @deprecated */ public function editPostAction($id) { $mapper = new WpProQuiz_Model_QuestionMapper(); if (isset($this->_post['submit']) && $mapper->existsAndWritable($id)) { $post = $this->_post; $post['id'] = $id; $post['title'] = isset($post['title']) ? trim($post['title']) : ''; $clearPost = $this->clearPost($post); $post['answerData'] = $clearPost['answerData']; if (empty($post['title'])) { $question = $mapper->fetch($id); $post['title'] = sprintf(__('Question: %d', 'wp-pro-quiz'), $question->getSort() + 1); } if ($post['answerType'] === 'assessment_answer') { $post['answerPointsActivated'] = 1; } if (isset($post['answerPointsActivated'])) { if (isset($post['answerPointsDiffModusActivated'])) { $post['points'] = $clearPost['maxPoints']; } else { $post['points'] = $clearPost['points']; } } $post['categoryId'] = $post['category'] > 0 ? $post['category'] : 0; $mapper->save(new WpProQuiz_Model_Question($post), true); WpProQuiz_View_View::admin_notices(__('Question edited', 'wp-pro-quiz'), 'info'); } }
private function deleteMultiAction() { if (!current_user_can('wpProQuiz_delete_quiz')) { wp_die(__('You do not have sufficient permissions to access this page.')); } $m = new WpProQuiz_Model_QuizMapper(); if (!empty($_POST['ids'])) { foreach ($_POST['ids'] as $id) { $m->deleteAll($id); } } WpProQuiz_View_View::admin_notices(__('Quiz deleted', 'wp-pro-quiz'), 'info'); $this->showAction(); }