From: <al...@us...> - 2008-10-17 20:18:48
|
Revision: 731 http://sciret.svn.sourceforge.net/sciret/?rev=731&view=rev Author: alpeb Date: 2008-10-17 20:18:46 +0000 (Fri, 17 Oct 2008) Log Message: ----------- Added ability to disable the Questions functionalities (we'll do that when KB is used with the monkeys) Modified Paths: -------------- trunk/actions/AddQuestion.php trunk/actions/DeleteQuestion.php trunk/actions/PublishQuestion.php trunk/actions/SavePreferences.php trunk/models/Configuration.php trunk/templates/EditPreferences.tpl trunk/templates/header.tpl trunk/views/AddQuestion.php trunk/views/EditPreferences.php trunk/views/MainView.php trunk/views/ManageQuestions.php trunk/views/View.php Modified: trunk/actions/AddQuestion.php =================================================================== --- trunk/actions/AddQuestion.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/actions/AddQuestion.php 2008-10-17 20:18:46 UTC (rev 731) @@ -15,6 +15,10 @@ class AddQuestion extends Action { function dispatch() { + if (!$this->configuration->getConfigValue('questionsEnabled')) { + die('The questions functionalities have been disabled'); + } + if ($_POST['username'] == '') { $_SESSION['message'] = $this->user->lang('You must enter your name'); Library::redirect(Library::getLink(array('view' => 'AddQuestion'))); Modified: trunk/actions/DeleteQuestion.php =================================================================== --- trunk/actions/DeleteQuestion.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/actions/DeleteQuestion.php 2008-10-17 20:18:46 UTC (rev 731) @@ -15,6 +15,10 @@ class DeleteQuestion extends Action { function dispatch() { + if (!$this->configuration->getConfigValue('questionsEnabled')) { + die('The questions functionalities have been disabled'); + } + $questionId = isset($_GET['id'])? (int)$_GET['id'] : 0; $questionGateway = new QuestionGateway; Modified: trunk/actions/PublishQuestion.php =================================================================== --- trunk/actions/PublishQuestion.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/actions/PublishQuestion.php 2008-10-17 20:18:46 UTC (rev 731) @@ -15,6 +15,10 @@ class PublishQuestion extends Action { function dispatch() { + if (!$this->configuration->getConfigValue('questionsEnabled')) { + die('The questions functionalities have been disabled'); + } + $qId = isset($_GET['id'])? (int)$_GET['id'] : 0; $questionGateway = new QuestionGateway; Modified: trunk/actions/SavePreferences.php =================================================================== --- trunk/actions/SavePreferences.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/actions/SavePreferences.php 2008-10-17 20:18:46 UTC (rev 731) @@ -37,6 +37,7 @@ if (($this->user->role & User::ROLE_ADMIN) == User::ROLE_ADMIN) { $this->configuration->setConfigValue('publishKB', $_POST['publishKB'] == '1'? '1' : '0'); $this->configuration->setConfigValue('anonymousRegistration', $_POST['anonymousRegistration'] == '1'? '1' : '0'); + $this->configuration->setConfigValue('questionsEnabled', $_POST['questionsEnabled'] == '1'? '1' : '0'); $this->configuration->setConfigValue('publishArticlesAuto', $_POST['publishArticlesAuto'] == '1'? '1' : '0'); $this->configuration->setConfigValue('publishBookmarksAuto', $_POST['publishBookmarksAuto'] == '1'? '1' : '0'); $this->configuration->setConfigValue('publishCommentsAuto', $_POST['publishCommentsAuto'] == '1'? '1' : '0'); Modified: trunk/models/Configuration.php =================================================================== --- trunk/models/Configuration.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/models/Configuration.php 2008-10-17 20:18:46 UTC (rev 731) @@ -15,6 +15,7 @@ // var name => array(defaultValue, isHidden) 'publishKB' => 1, 'anonymousRegistration' => 0, + 'questionsEnabled' => 1, 'publishArticlesAuto' => 1, 'publishBookmarksAuto' => 1, 'publishCommentsAuto' => 1, Modified: trunk/templates/EditPreferences.tpl =================================================================== --- trunk/templates/EditPreferences.tpl 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/templates/EditPreferences.tpl 2008-10-17 20:18:46 UTC (rev 731) @@ -85,6 +85,15 @@ </select> </td> </tr> + <tr> + <td class="form_left">[l]Enable the Questions functionalities[/l]:</td> + <td> + <select name="questionsEnabled"> + <option value="1" {questionsEnabled_yes_selected}>[l]Yes[/l]</option> + <option value="0" {questionsEnabled_no_selected}>[l]No[/l]</option> + </select> + </td> + </tr> <tr class="row_off"> <td class="form_left">[l]Publish articles automatically[/l]:</td> <td> Modified: trunk/templates/header.tpl =================================================================== --- trunk/templates/header.tpl 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/templates/header.tpl 2008-10-17 20:18:46 UTC (rev 731) @@ -30,12 +30,14 @@ <span class="button_green"><a href="index.php?action=Logout">[l]Logout[/l]</a></span> <!-- END logoutLink_block --> </p> + <!-- BEGIN questionButtons_block --> <p> <span class="button_light"><a href="{addQuestionHref}">[l]Submit Question[/l]</a></span> <!-- BEGIN manageQuestionsLink_block --> <span class="button_light"><a href="{manageQuestionsHref}">[l]Manage Questions[/l]</a></span> <!-- END manageQuestionsLink_block --> </p> + <!-- END questionButtons_block --> </div> </div><!--end head--> Modified: trunk/views/AddQuestion.php =================================================================== --- trunk/views/AddQuestion.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/views/AddQuestion.php 2008-10-17 20:18:46 UTC (rev 731) @@ -15,6 +15,9 @@ class AddQuestion extends view { function dispatch() { + if (!$this->configuration->getConfigValue('questionsEnabled')) { + die('The questions functionalities have been disabled'); + } $this->tpl->set_file('addQuestion', 'AddQuestion.tpl'); $this->tpl->set_block('addQuestion', 'categories_block', 'categories'); Modified: trunk/views/EditPreferences.php =================================================================== --- trunk/views/EditPreferences.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/views/EditPreferences.php 2008-10-17 20:18:46 UTC (rev 731) @@ -40,6 +40,8 @@ 'publishKB_no_selected' => $this->configuration->getConfigValue('publishKB') == '0'? 'selected="true"' : '', 'anonymousRegistration_yes_selected' => $this->configuration->getConfigValue('anonymousRegistration') == '1'? 'selected="true"' : '', 'anonymousRegistration_no_selected' => $this->configuration->getConfigValue('anonymousRegistration') == '0'? 'selected="true"' : '', + 'questionsEnabled_yes_selected' => $this->configuration->getConfigValue('questionsEnabled') == '1'? 'selected="true"' : '', + 'questionsEnabled_no_selected' => $this->configuration->getConfigValue('questionsEnabled') == '0'? 'selected="true"' : '', 'publishArticlesAuto_yes_selected' => $this->configuration->getConfigValue('publishArticlesAuto') == '1'? 'selected="true" ': '', 'publishArticlesAuto_no_selected' => $this->configuration->getConfigValue('publishArticlesAuto') == '0'? 'selected="true" ': '', 'publishBookmarksAuto_yes_selected' => $this->configuration->getConfigValue('publishBookmarksAuto') == '1'? 'selected="true" ': '', Modified: trunk/views/MainView.php =================================================================== --- trunk/views/MainView.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/views/MainView.php 2008-10-17 20:18:46 UTC (rev 731) @@ -278,37 +278,39 @@ } // ** UNANSWERED QUESTIONS LIST ** - $questionGateway = new QuestionGateway; - $questions = $questionGateway->getQuestions($catId, true); - $firstIteration = true; - while ($question = $questions->fetch()) { - unset($this->tPath); - if ($question->getCategoryId() > 0) { - $path = $this->_getCategoryPath($question->getCategoryId(), 'MainView', false); - $this->tpl->set_var('questionCategory', $this->user->lang('in %s', $path)); - } else { - $this->tpl->set_var('questionCategory', ''); + if ($this->configuration->getConfigValue('questionsEnabled')) { + $questionGateway = new QuestionGateway; + $questions = $questionGateway->getQuestions($catId, true); + $firstIteration = true; + while ($question = $questions->fetch()) { + unset($this->tPath); + if ($question->getCategoryId() > 0) { + $path = $this->_getCategoryPath($question->getCategoryId(), 'MainView', false); + $this->tpl->set_var('questionCategory', $this->user->lang('in %s', $path)); + } else { + $this->tpl->set_var('questionCategory', ''); + } + $this->tpl->set_var(array( + 'answerLink' => Library::getLink(array('view' => 'EditArticle', 'qId' => $question->getId())), + 'questionSummary' => $question->getContents(), + 'questionUserName' => $question->getUserName(), + )); + + if (!$this->user->isAnonymous()) { + $this->tpl->parse('answerLink', 'answerLink_block'); + } else { + $this->tpl->set_var('answerLink', ''); + } + + $this->tpl->parse('unansweredQuestionsItem', 'unansweredQuestionsItem_block', !$firstIteration); + $firstIteration = false; } - $this->tpl->set_var(array( - 'answerLink' => Library::getLink(array('view' => 'EditArticle', 'qId' => $question->getId())), - 'questionSummary' => $question->getContents(), - 'questionUserName' => $question->getUserName(), - )); - - if (!$this->user->isAnonymous()) { - $this->tpl->parse('answerLink', 'answerLink_block'); + if ($firstIteration) { + $this->tpl->set_var('unansweredQuestions', ''); } else { - $this->tpl->set_var('answerLink', ''); + $this->tpl->parse('unansweredQuestions', 'unansweredQuestions_block'); } - - $this->tpl->parse('unansweredQuestionsItem', 'unansweredQuestionsItem_block', !$firstIteration); - $firstIteration = false; } - if ($firstIteration) { - $this->tpl->set_var('unansweredQuestions', ''); - } else { - $this->tpl->parse('unansweredQuestions', 'unansweredQuestions_block'); - } $this->tpl->pparse('out', 'main'); } Modified: trunk/views/ManageQuestions.php =================================================================== --- trunk/views/ManageQuestions.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/views/ManageQuestions.php 2008-10-17 20:18:46 UTC (rev 731) @@ -16,6 +16,10 @@ class ManageQuestions extends View { function dispatch() { + if (!$this->configuration->getConfigValue('questionsEnabled')) { + die('The questions functionalities have been disabled'); + } + $catId = isset($_GET['catId'])? (int)$_GET['catId'] : 0; $this->tpl->set_file('manageQuestions', 'ManageQuestions.tpl'); Modified: trunk/views/View.php =================================================================== --- trunk/views/View.php 2008-10-17 17:17:21 UTC (rev 730) +++ trunk/views/View.php 2008-10-17 20:18:46 UTC (rev 731) @@ -73,7 +73,8 @@ $this->tpl->set_block('header', 'loginLink_block', 'loginLink'); $this->tpl->set_block('header', 'registerLink_block', 'registerLink'); $this->tpl->set_block('header', 'welcome_block', 'welcome'); - $this->tpl->set_block('header', 'manageQuestionsLink_block', 'manageQuestionsLink'); + $this->tpl->set_block('header', 'questionButtons_block', 'questionButtons'); + $this->tpl->set_block('questionButtons_block', 'manageQuestionsLink_block', 'manageQuestionsLink'); if ($this->user->isAnonymous()) { $this->tpl->set_var('welcome', ''); @@ -89,6 +90,12 @@ $this->tpl->parse('manageQuestionsLink', 'manageQuestionsLink_block'); } + if ($this->configuration->getConfigValue('questionsEnabled')) { + $this->tpl->parse('questionButtons', 'questionButtons_block'); + } else { + $this->tpl->set_var('questionButtons', ''); + } + if ($this->user->isAnonymous() && $this->configuration->getConfigValue('anonymousRegistration')) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |