From cd7ab56874bc3ed6bda377d08d436f8d89bd7404 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 4 Apr 2011 22:04:36 -0700 Subject: [PATCH] QnA * show number of answers on question notices * change label on answer submit button to "Answer" --- plugins/QnA/classes/QnA_Question.php | 14 ++++++++++++-- plugins/QnA/lib/qnanewanswerform.php | 2 +- plugins/QnA/lib/qnashowanswerform.php | 12 ++++++++++-- plugins/QnA/lib/qnashowquestionform.php | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/plugins/QnA/classes/QnA_Question.php b/plugins/QnA/classes/QnA_Question.php index 7055876369..157eaa7a18 100644 --- a/plugins/QnA/classes/QnA_Question.php +++ b/plugins/QnA/classes/QnA_Question.php @@ -189,9 +189,11 @@ class QnA_Question extends Managed_DataObject function countAnswers() { - $a = new QnA_Answer(); + $a = new QnA_Answer(); + $a->question_id = $this->id; - return $a-count(); + + return $a->count(); } static function fromNotice($notice) @@ -221,6 +223,14 @@ class QnA_Question extends Managed_DataObject $out->elementEnd('span'); } + $cnt = $question->countAnswers(); + + if (!empty($cnt)) { + $out->elementStart('span', 'answer-count'); + $out->text(sprintf(_m('%s answers'), $cnt)); + $out->elementEnd('span'); + } + if (!empty($question->closed)) { $out->elementStart('span', 'question-closed'); $out->text(_m('This question is closed.')); diff --git a/plugins/QnA/lib/qnanewanswerform.php b/plugins/QnA/lib/qnanewanswerform.php index db4d1dfafc..a0f4cd4b22 100644 --- a/plugins/QnA/lib/qnanewanswerform.php +++ b/plugins/QnA/lib/qnanewanswerform.php @@ -118,7 +118,7 @@ class QnanewanswerForm extends Form function formActions() { // TRANS: Button text for submitting a poll response. - $this->out->submit('submit', _m('BUTTON', 'Submit')); + $this->out->submit('submit', _m('BUTTON', 'Answer')); } } diff --git a/plugins/QnA/lib/qnashowanswerform.php b/plugins/QnA/lib/qnashowanswerform.php index 5ec63e1096..890224ed69 100644 --- a/plugins/QnA/lib/qnashowanswerform.php +++ b/plugins/QnA/lib/qnashowanswerform.php @@ -65,8 +65,8 @@ class QnashowanswerForm extends Form { parent::__construct($out); - $this->answer = $answer; - $this->question = $answer->getQuestion(); + $this->answer = $answer; + $this->question = $answer->getQuestion(); } /** @@ -155,6 +155,13 @@ class QnashowanswerForm extends Form } } + + /* + * @fixme: Revise is disabled until we figure out the + * Ostatus bits This comment is just a reminder + * that the UI for this works. + */ + /* if ($user->id == $this->answer->profile_id) { $this->out->submit( 'revise', @@ -166,6 +173,7 @@ class QnashowanswerForm extends Form _('Revise your answer') ); } + */ } } diff --git a/plugins/QnA/lib/qnashowquestionform.php b/plugins/QnA/lib/qnashowquestionform.php index 71e644e2dc..ad29d0d018 100644 --- a/plugins/QnA/lib/qnashowquestionform.php +++ b/plugins/QnA/lib/qnashowquestionform.php @@ -118,7 +118,7 @@ class QnashowquestionForm extends Form 'question-' . $this->question->id ); - $this->out->raw($this->question->asHTML()); + $this->out->raw($this->question->asHTML()); } /** -- 2.39.5