123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class QnashowquestionAction extends ShownoticeAction
- {
- protected $question = null;
-
- function prepare(array $args = [])
- {
- Action::prepare($args);
- $this->id = $this->trimmed('id');
- $this->question = QnA_Question::getKV('id', $this->id);
- if (empty($this->question)) {
-
- throw new ClientException(_m('No such question.'), 404);
- }
- $this->notice = $this->question->getNotice();
- if (empty($this->notice)) {
-
-
- throw new ClientException(_m('No such question notice.'), 404);
- }
- $this->user = User::getKV('id', $this->question->profile_id);
- if (empty($this->user)) {
-
- throw new ClientException(_m('No such user.'), 404);
- }
- $this->profile = $this->user->getProfile();
- if (empty($this->profile)) {
-
- throw new ServerException(_m('User without a profile.'));
- }
- try {
- $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
- } catch (Exception $e) {
- $this->avatar = null;
- }
- return true;
- }
- function showContent()
- {
- $this->elementStart('div', 'qna-full-question');
- $this->raw($this->question->asHTML());
- $answer = $this->question->getAnswers();
- $this->elementStart('div', 'qna-full-question-answers');
- $answerIds = array();
-
- if (!empty($answer)) {
- while ($answer->fetch()) {
- $answerIds[] = $answer->getNotice()->id;
- }
- }
- if (count($answerIds) > 0) {
- $notice = Notice::multiGet('id', $answerIds);
- $nli = new NoticeList($notice, $this);
- $nli->show();
- }
- $user = common_current_user();
- if (!empty($user)) {
- $profile = $user->getProfile();
- $answer = QnA_Question::getAnswer($profile);
- if (empty($answer)) {
- $form = new QnanewanswerForm($this, $this->question, false);
- $form->show();
- }
- }
- $this->elementEnd('div');
- $this->elementEnd('div');
- }
-
- function title()
- {
- return sprintf(
-
-
- _m('%1$s\'s question: %2$s'),
- $this->user->nickname,
- $this->question->title
- );
- }
-
- function lastModified()
- {
- return Action::lastModified();
- }
-
- function etag()
- {
- return Action::etag();
- }
- }
|