/**
  * Generates the html of the answer form
  * OR an html block explaining why form is not
  * available (like when question is marked as closed)
  * and also setting the 'mustLogin' related elements
  * if user not logged in
  *
  * @param \Lampcms\Question $Question
  *
  * @return string html of form or message block
  */
 public function getAnswerForm(\Lampcms\Question $Question)
 {
     //d('cp');
     /**
      * A custom observer may cancel the onBeforeAnswerform event
      * in order to NOT display the form
      * For example, a filter (implemented as an observer)
      * may decide not to show an answer form to users
      * from rough states based on GeoLocation by IP
      * For example - don't show answer form in China
      * OR NOT show answer form based on Viewer object if viewer
      * has been flagged as spammer
      */
     $oNotification = $this->Registry->Dispatcher->post($Question, 'onBeforeAnswerForm');
     //d('cp');
     if ($oNotification->isNotificationCancelled()) {
         d('onBeforeAnswerform cancelled by observer');
         return '';
     }
     //d('cp');
     /**
      * If questions is closed then
      * instead of answer form return
      * the div with "closed" message
      */
     if (false !== ($aClosed = $Question->isClosed())) {
         return \tplClosedby::parse($aClosed);
     }
     //d('cp');
     $formTitle = 0 === $Question['i_ans'] ? '@@Be the first to answer this question@@' : '@@Your answer@@';
     $this->setVar('title', $formTitle);
     $this->setVar('qid', $Question['_id']);
     //$this->setVar('submit', $this->Tr['Submit answer']);
     //$this->setVar('preview', $this->Tr['Preview']);
     if ($this->Registry->Viewer->isGuest()) {
         //d('cp');
         $this->qbody = '@@Please login to post your answer@@';
         $this->com_hand = ' com_hand';
         $this->readonly = 'readonly="readonly"';
         $this->disabled = ' disabled="disabled"';
         $oQuickReg = new \Lampcms\RegBlockQuickReg($this->Registry);
         //d('cp');
         $socialButtons = LoginForm::makeSocialButtons($this->Registry);
         if (!empty($socialButtons)) {
             $this->connectBlock = '<div class="com_connect"><h3>@@Join with account you already have@@</h3>' . $socialButtons . '</div>';
         }
     }
     //d('cp');
     $form = $this->getForm();
     return $form;
 }
Beispiel #2
0
 /**
  * This method is called from Login and
  * from wwwOauth, thus its here in one place
  *
  * @return array of user profile and welcome html div
  * if user is logged in, or empty array otherwise
  */
 protected function makeLoginArray()
 {
     $a = array();
     d('cp');
     if ($this->isLoggedIn()) {
         $welcome = LoginForm::makeWelcomeMenu($this->Registry);
         $a['welcome'] = $welcome;
     }
     d('cp');
     //d('a: '.print_r($a, 1));
     return $a;
 }
Beispiel #3
0
 /**
  * Set classnames based on user logged in status
  * not logged in user will get com_hand class
  * which in turn will trigger popup on click
  * on the form element
  *
  * @return object $this
  */
 protected function setMustLogin()
 {
     if (!$this->isLoggedIn()) {
         $this->Form->qbody = $this->_('Please login to post your question');
         $this->Form->com_hand = ' com_hand';
         $this->Form->readonly = 'readonly="readonly"';
         $this->Form->disabled = ' disabled="disabled"';
         $oQuickReg = new RegBlockQuickReg($this->Registry);
         $socialButtons = LoginForm::makeSocialButtons($this->Registry);
         /**
          * @todo Translate string
          */
         if (!empty($socialButtons)) {
             $this->Form->connectBlock = '<div class="com_connect"><h3>' . $this->_('Join with account you already have') . '</h3>' . $socialButtons . '</div>';
         }
     }
     return $this;
 }