return true;
}
+ /**
+ * Output our CSS class for QnA notice list elements
+ *
+ * @param NoticeListItem $nli The item being shown
+ *
+ * @return boolean hook value
+ */
+
+ function onStartOpenNoticeListItemElement($nli)
+ {
+
+ $type = $nli->notice->object_type;
+
+ switch($type)
+ {
+ case QnA_Question::OBJECT_TYPE:
+ $id = (empty($nli->repeat)) ? $nli->notice->id : $nli->repeat->id;
+ $nli->out->elementStart(
+ 'li', array(
+ 'class' => 'hentry notice question',
+ 'id' => 'notice-' . $id
+ )
+ );
+ Event::handle('EndOpenNoticeListItemElement', array($nli));
+ return false;
+ break;
+ case QnA_Answer::OBJECT_TYPE:
+ $id = (empty($nli->repeat)) ? $nli->notice->id : $nli->repeat->id;
+ $nli->out->elementStart(
+ 'li', array(
+ 'class' => 'hentry notice answer',
+ 'id' => 'notice-' . $id
+ )
+ );
+ Event::handle('EndOpenNoticeListItemElement', array($nli));
+ return false;
+ break;
+ default:
+ return true;
+ }
+
+ return true;
+ }
+
/**
* Custom HTML output for our notices
*
$nli = new NoticeListItem($notice, $out);
$nli->showNotice();
- $out->elementStart('div', array('class' => 'entry-content question-content'));
+
+
+ $out->elementStart('div', array('class' => 'entry-content question-desciption'));
+
$question = QnA_Question::getByNotice($notice);
- if ($question) {
- if ($user) {
- $profile = $user->getProfile();
- $answer = $question->getAnswer($profile);
- if ($answer) {
- // User has already answer; show the results.
- $form = new QnareviseanswerForm($answer, $out);
- } else {
- $form = new QnaanswerForm($question, $out);
+ if (!empty($question)) {
+
+ $short = $question->description;
+ $out->raw($question->description);
+
+ // Don't prompt user for an answer if the question is closed or
+ // the current user posed the question in the first place
+ if (empty($question->closed)) {
+ if (!empty($user) && ($user->id != $question->profile_id)) {
+ $profile = $user->getProfile();
+ $answer = $question->getAnswer($profile);
+ if ($answer) {
+ // User has already answered; show the results.
+ $form = new QnareviseanswerForm($answer, $out);
+ } else {
+ $form = new QnaanswerForm($question, $out);
+ }
+ $form->show();
}
- $form->show();
}
} else {
- $out->text(_m('Question data is missing'));
+ $out->text(_m('Question data is missing.'));
}
$out->elementEnd('div');
$nli = new NoticeListItem($notice, $out);
$nli->showNotice();
+ $out->elementStart('div', array('class' => 'entry-content answer-content'));
+
+ $answer = QnA_Answer::staticGet('uri', $notice->uri);
+
+ if (!empty($answer)) {
+ $short = $answer->content;
+ $out->raw($answer->content);
+ } else {
+ $out->text(_m('Answer data is missing.'));
+ }
+
+ $out->elementEnd('div');
+
// @fixme
$out->elementStart('div', array('class' => 'entry-content'));
}
*/
function newAnswer()
{
+ $profile = $this->user->getProfile();
+
try {
$notice = QnA_Answer::saveNew(
- $this->user->getProfile(),
+ $profile,
$this->question,
$this->answerText
);
}
if ($this->boolean('ajax')) {
common_debug("ajaxy part");
+ $answer = $this->question->getAnswer($profile);
header('Content-Type: text/xml;charset=utf-8');
$this->xw->startDocument('1.0', 'UTF-8');
$this->elementStart('html');
$this->element('title', null, _m('Answers'));
$this->elementEnd('head');
$this->elementStart('body');
- $this->raw($this->answer->asHTML());
+ $this->raw($answer->asHTML());
$this->elementEnd('body');
$this->elementEnd('html');
} else {