/** * Load the form */ private function loadForm() { // create form $this->frm = new FrontendForm('own_question', '#' . FL::getAction('OwnQuestion')); $this->frm->addText('name')->setAttributes(array('required' => null)); $this->frm->addText('email')->setAttributes(array('required' => null, 'type' => 'email')); $this->frm->addTextarea('message')->setAttributes(array('required' => null)); }
/** * * Get all the users for a group * * @param $id * * @return array() */ public static function getAddressesForGroup($id, $search = "", $orderby = false) { $strOr = ""; $strWhere = ""; $strOrderBy = ""; if ($orderby != false) { $strOrderBy = " ORDER BY " . $orderby; } //--Check if search is filled in if ($search != "") { $returnTemp = array(); //--Search fields $fields = array("company", "address", "zipcode", "city", "fax", "website", "email"); $arrSearch = explode(" ", $search); foreach ($arrSearch as $rowSearch) { //--Reset or $strOr = ''; $strWhere = " AND ("; //--Loop all the field to search in foreach ($fields as $field) { $strWhere .= $strOr . " {$field} LIKE '%" . $rowSearch . "%'"; $strOr = " OR "; } $strWhere .= ")"; $returnSearch = FrontendModel::getContainer()->get('database')->getRecords("SELECT i.address_id, a.name, a.firstname, a.company, a.address, a.zipcode, a.city, a.country, a.phone, a.fax, a.email, a.website, a.lat, a.lng, a.contact, a.assort, a.vat, a.size, a.open, a.closed, a.visit, m.url, m.data as meta_data\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM addresses_in_group AS i\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN addresses AS a ON a.id = i.address_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN meta AS m ON m.id = a.meta_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE i.group_id = ? AND a.hidden=? {$strWhere} {$strOrderBy}", array($id, 'N')); if (!empty($returnSearch)) { $returnTemp = array_merge($returnTemp, $returnSearch); } } if (!empty($returnTemp)) { foreach ($returnTemp as $key => $row) { $return[$row['address_id']] = $row; } } } else { $return = FrontendModel::getContainer()->get('database')->getRecords("SELECT i.address_id, a.name, a.firstname, a.company, a.address, a.zipcode, a.city, a.country, a.phone, a.fax, a.email, a.website, a.lat, a.lng, a.contact, a.assort, a.vat, a.size, a.open, a.closed, a.visit, m.url, m.data as meta_data\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM addresses_in_group AS i\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN addresses AS a ON a.id = i.address_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN meta AS m ON m.id = a.meta_id\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE i.group_id = ? AND a.hidden=? {$strWhere} {$strOrderBy}", array($id, 'N')); } //--Get link for the categories $detailLink = FrontendNavigation::getURLForBlock('Addresses', 'Detail'); //--Get folders $folders = FrontendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/addresses/images', true); if (!empty($return)) { // loop items and unserialize foreach ($return as &$row) { $row['company'] = self::replaceCharacters($row['company']); $row['full_url'] = "/" . strtolower(FRONTEND_LANGUAGE) . "/" . FL::getAction('Adressen') . '/' . FL::getAction('detail') . '/' . $row['url']; if (isset($row['meta_data'])) { $row['meta_data'] = @unserialize($row['meta_data']); } // image? if (isset($row['image'])) { foreach ($folders as $folder) { $row['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $row['image']; } } } } return $return; }
/** * 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 ($this->get('fork.settings')->get('Faq', 'send_email_on_new_feedback')) { // add the question $variables['question'] = $this->record['question']; $to = $this->get('fork.settings')->get('Core', 'mailer_to'); $from = $this->get('fork.settings')->get('Core', 'mailer_from'); $replyTo = $this->get('fork.settings')->get('Core', 'mailer_reply_to'); $message = \Common\Mailer\Message::newInstance(sprintf(FL::getMessage('FaqFeedbackSubject'), $this->record['question']))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml(FRONTEND_MODULES_PATH . '/Faq/Layout/Templates/Mails/Feedback.tpl', $variables, true); } } // trigger event FrontendModel::triggerEvent('Faq', 'after_add_feedback', array('comment' => $text)); // save status $this->redirect($this->record['full_url'] . '/' . FL::getAction('Success')); } } else { // form hasn't been sent $this->tpl->assign('hideFeedbackNoInfo', true); } }