Esempio n. 1
0
 /**
  * Load the data, don't forget to validate the incoming data
  *
  * @return	void
  */
 private function getData()
 {
     // get questions
     $this->items = FrontendFaqModel::getCategories();
     // go over categories
     foreach ($this->items as &$item) {
         // add questions info to array
         $item['questions'] = FrontendFaqModel::getQuestions($item['id']);
     }
 }
Esempio n. 2
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $categories = FrontendFaqModel::getCategories();
     $limit = FrontendModel::getModuleSetting('faq', 'overview_num_items_per_category', 10);
     foreach ($categories as $item) {
         $item['questions'] = FrontendFaqModel::getAllForCategory($item['id'], $limit);
         // no questions? next!
         if (empty($item['questions'])) {
             continue;
         }
         // add the category item including the questions
         $this->items[] = $item;
     }
 }
Esempio n. 3
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get by URL
     $this->record = FrontendFaqModel::getCategory($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('faq', 'category') . '/' . $this->record['url'];
     $this->questions = FrontendFaqModel::getAllForCategory($this->record['id']);
 }
Esempio n. 4
0
 /**
  * Parse
  */
 private function parse()
 {
     $this->tpl->assign('widgetFaqMostRead', FrontendFaqModel::getMostRead(FrontendModel::getModuleSetting('faq', 'most_read_num_items', 10)));
 }
Esempio n. 5
0
 /**
  * Parse the data into the template
  *
  * @return	void
  */
 private function parse()
 {
     // assign questions
     $this->tpl->assign('faqQuestions', FrontendFaqModel::getQuestions((int) $this->data['id']));
 }
Esempio n. 6
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     $feedbackAllowed = isset($this->settings['allow_feedback']) && $this->settings['allow_feedback'];
     if (!$feedbackAllowed) {
         return false;
     }
     if ($this->frm->isSubmitted()) {
         // reformat data
         $useful = $this->frm->getField('useful')->getValue() == 'Y';
         // the form has been sent
         $this->tpl->assign('hideFeedbackNoInfo', $useful);
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate required fields
         if (!$useful) {
             $this->frm->getField('message')->isFilled(FL::err('FeedbackIsRequired'));
         }
         if ($this->frm->isCorrect()) {
             // reformat data
             $text = $this->frm->getField('message')->getValue();
             // get feedback in session
             $previousFeedback = SpoonSession::exists('faq_feedback_' . $this->record['id']) ? SpoonSession::get('faq_feedback_' . $this->record['id']) : null;
             // update counters
             FrontendFaqModel::updateFeedback($this->record['id'], $useful, $previousFeedback);
             // save feedback in session
             SpoonSession::set('faq_feedback_' . $this->record['id'], $useful);
             // answer is yes so there's no feedback
             if (!$useful) {
                 // get module setting
                 $spamFilterEnabled = isset($this->settings['spamfilter']) && $this->settings['spamfilter'];
                 // build array
                 $variables['question_id'] = $this->record['id'];
                 $variables['sentOn'] = time();
                 $variables['text'] = $text;
                 // should we check if the item is spam
                 if ($spamFilterEnabled) {
                     // the comment is spam
                     if (FrontendModel::isSpam($text, $variables['question_link'])) {
                         // set the status to spam
                         $this->redirect($this->record['full_url'] . '/' . FL::getAction('Spam'));
                     }
                 }
                 // save the feedback
                 FrontendFaqModel::saveFeedback($variables);
                 // send email on new feedback?
                 if (FrontendModel::getModuleSetting('faq', 'send_email_on_new_feedback')) {
                     // add the question
                     $variables['question'] = $this->record['question'];
                     // add the email
                     FrontendMailer::addEmail(sprintf(FL::getMessage('FaqFeedbackSubject'), $this->record['question']), FRONTEND_MODULES_PATH . '/faq/layout/templates/mails/feedback.tpl', $variables);
                 }
             }
             // trigger event
             FrontendModel::triggerEvent('faq', 'after_add_feedback', array('comment' => $text));
             // save status
             $this->redirect($this->record['full_url'] . '/' . FL::getAction('Success'));
         }
     } else {
         $this->tpl->assign('hideFeedbackNoInfo', true);
     }
 }