function _replaceTags($text, rfanswers $answers) { // Price if (strstr($text, '[totalprice]')) { $text = str_replace('[totalprice]', $answers->getPrice(), $text); } $matches = array(); if (!preg_match_all('(\\[answer_[0-9]+\\])', $text, $matches)) { return $text; } foreach ($matches[0] as $tag) { // get field id from tag $id = substr($tag, 8, -1); foreach ($answers->getAnswers() as $field) { if ($field['field_id'] == $id) { $text = str_replace($tag, $field['value'], $text); break; } } } return $text; }
function store() { echo '<pre>'; print_r('deprecated ?'); echo '</pre>'; exit; $mainframe =& JFactory::getApplication(); $db =& $this->_db; /* Default values */ $answer = ''; $return = false; $redcompetition = false; $redevent = false; $event_task = JRequest::getVar('event_task'); $submitter_id = Jrequest::getInt('submitter_id', 0); if ($submitter_id) { $submitter = $this->getSubmitter($submitter_id); $submit_key = $submitter->submit_key; } else { $submitter = false; $submit_key = uniqid(); } /* Get the form details */ $form = $this->getForm(JRequest::getInt('form_id')); /* Load the fields */ $fieldlist = $this->getfields($form->id); /* Load the posted variables */ $post = JRequest::get('post'); $files = JRequest::get('files'); $posted = array_merge($post, $files); /* See if we have an event ID */ if (JRequest::getInt('event_xref', 0)) { $redevent = true; $posted['xref'] = JRequest::getInt('event_xref', 0); } else { if (isset($post['integration']) && $post['integration'] == 'redevent') { $redevent = true; $posted['xref'] = JRequest::getInt('xref', 0); } else { if (JRequest::getInt('competition_id', 0)) { $redcompetition = true; $posted['xref'] = JRequest::getInt('competition_id', 0); } else { $posted['xref'] = 0; } } } if ($posted['xref'] && $redevent) { $event = $this->getEvent($posted['xref']); } else { $event = null; } // new answers object $answers = new rfanswers(); $answers->setFormId($form->id); if ($event) { $answers->initPrice($event->course_price); } /* Create an array of values to store */ $postvalues = array(); // remove the _X parts, where X is the form (signup) number $signup = 1; foreach ($posted as $key => $value) { if (strpos($key, 'field') === 0 && strpos($key, '_' . $signup, 5) > 0) { $postvalues[str_replace('_' . $signup, '', $key)] = $value; } } /* Some default values needed */ $postvalues['xref'] = $post['xref']; $postvalues['form_id'] = $post['form_id']; $postvalues['submit_key'] = $submit_key; if (isset($post['integration'])) { $postvalues['integration'] = $post['integration']; } /* Get the raw form data */ $postvalues['rawformdata'] = serialize($posted); /* Build up field list */ foreach ($fieldlist as $key => $field) { if (isset($postvalues['field' . $key])) { /* Get the answers */ try { $answers->addPostAnswer($field, $postvalues['field' . $key]); } catch (Exception $e) { $this->setError($e->getMessage()); return false; } } } if ($submitter) { // this 'anwers' were already posted $answers->setAnswerId($submitter->answer_id); } // save answers if (!$answers->save($postvalues)) { return false; } // add an attendee in redevent ? $uid = JRequest::getInt('uid'); $this->updateMailingList($answers); return true; }