示例#1
0
 public function getTemplate()
 {
     $app = JFactory::getApplication();
     $Itemid = $this->getItemId();
     $has_suffix = JFactory::getConfig()->get('sef') && JFactory::getConfig()->get('sef_suffix');
     $layout = $app->input->getCmd('layout', 'default');
     // Templates
     $template_module = $this->params->def('template_module', '');
     $template_formdatarow = $this->params->def('template_formdatarow', '');
     $template_formdetail = $this->params->def('template_formdetail', '');
     if ($layout == 'default') {
         $formdata = '';
         $submissions = $this->getSubmissions();
         $headers = $this->getHeaders();
         $pagination = $this->getPagination();
         $i = 0;
         foreach ($submissions as $SubmissionId => $submission) {
             list($replace, $with) = $this->getReplacements($submission['UserId']);
             $pdf_link = JRoute::_('index.php?option=com_rsform&view=submissions&layout=view&cid=' . $SubmissionId . '&format=pdf' . $Itemid);
             if ($has_suffix) {
                 $pdf_link .= strpos($pdf_link, '?') === false ? '?' : '&';
                 $pdf_link .= 'format=pdf';
             }
             $details_link = JRoute::_('index.php?option=com_rsform&view=submissions&layout=view&cid=' . $SubmissionId . $Itemid);
             $replacements = array('{global:userip}' => $submission['UserIp'], '{global:date_added}' => RSFormProHelper::getDate($submission['DateSubmitted']), '{global:submissionid}' => $SubmissionId, '{global:submission_id}' => $SubmissionId, '{global:counter}' => $pagination->getRowOffset($i), '{global:confirmed}' => $submission['confirmed'], '{details}' => '<a href="' . $details_link . '">', '{details_link}' => $details_link, '{detailspdf}' => '<a href="' . $pdf_link . '">', '{detailspdf_link}' => $pdf_link, '{_STATUS:value}' => isset($submission['SubmissionValues']['_STATUS']) ? JText::_('RSFP_PAYPAL_STATUS_' . $submission['SubmissionValues']['_STATUS']['Value']) : '');
             $replace = array_merge($replace, array_keys($replacements));
             $with = array_merge($with, array_values($replacements));
             foreach ($headers as $header) {
                 if (!isset($submission['SubmissionValues'][$header]['Value'])) {
                     $submission['SubmissionValues'][$header]['Value'] = '';
                 }
                 if (!empty($submission['SubmissionValues'][$header]['Path'])) {
                     $replace[] = '{' . $header . ':path}';
                     $with[] = $submission['SubmissionValues'][$header]['Path'];
                 }
             }
             list($replace2, $with2) = RSFormProHelper::getReplacements($SubmissionId, true);
             $replace = array_merge($replace, $replace2);
             $with = array_merge($with, $with2);
             $rowdata = $template_formdatarow;
             // Add scripting
             if (strpos($rowdata, '{/if}') !== false) {
                 require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/scripting.php';
                 RSFormProScripting::compile($rowdata, $replace, $with);
             }
             $formdata .= str_replace($replace, $with, $rowdata);
             $i++;
         }
         $html = str_replace('{formdata}', $formdata, $template_module);
     } else {
         $cid = $app->input->getInt('cid');
         $format = $app->input->getCmd('format');
         $user = JFactory::getUser();
         $userId = $this->params->def('userId', 0);
         if ($userId != 'login' && $userId != 0) {
             $userId = explode(',', $userId);
             JArrayHelper::toInteger($userId);
         }
         // Grab submission
         $this->_db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . $cid . "'");
         $submission = $this->_db->loadObject();
         // Submission doesn't exist
         if (!$submission) {
             JError::raiseWarning(500, JText::sprintf('RSFP_SUBMISSION_DOES_NOT_EXIST', $cid));
             return $app->redirect(JURI::root());
         }
         // Submission doesn't belong to the configured form ID OR
         // can view only own submissions and not his own OR
         // can view only specified user IDs and this doesn't belong to any of the IDs
         if ($submission->FormId != $this->params->get('formId') || $userId == 'login' && $submission->UserId != $user->get('id') || is_array($userId) && !in_array($user->get('id'), $userId)) {
             JError::raiseWarning(500, JText::sprintf('RSFP_SUBMISSION_NOT_ALLOWED', $cid));
             return $app->redirect(JURI::root());
         }
         if ($this->params->get('show_confirmed', 0) && !$submission->confirmed) {
             JError::raiseWarning(500, JText::sprintf('RSFP_SUBMISSION_NOT_CONFIRMED', $cid));
             return $app->redirect(JURI::root());
         }
         $pdf_link = JRoute::_('index.php?option=com_rsform&view=submissions&layout=view&cid=' . $cid . '&format=pdf' . $Itemid);
         if ($has_suffix) {
             $pdf_link .= strpos($pdf_link, '?') === false ? '?' : '&';
             $pdf_link .= 'format=pdf';
         }
         list($replace, $with) = RSFormProHelper::getReplacements($cid, true);
         list($replace2, $with2) = $this->getReplacements($submission->UserId);
         $replacements = array('{global:userip}' => $submission->UserIp, '{global:date_added}' => RSFormProHelper::getDate($submission->DateSubmitted), '{global:submissionid}' => $cid, '{global:submission_id}' => $cid, '{global:confirmed}' => $submission->confirmed ? JText::_('RSFP_YES') : JText::_('RSFP_NO'), '{detailspdf}' => '<a href="' . $pdf_link . '">', '{detailspdf_link}' => $pdf_link);
         $replace = array_merge($replace, $replace2, array_keys($replacements));
         $with = array_merge($with, $with2, array_values($replacements));
         if ($format == 'pdf' && preg_match_all('#{detailspdf}(.*?){\\/detailspdf}#is', $template_formdetail, $matches)) {
             foreach ($matches[0] as $fullmatch) {
                 $template_formdetail = str_replace($fullmatch, '', $template_formdetail);
             }
         }
         // Add scripting
         if (strpos($template_formdetail, '{/if}') !== false) {
             require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/scripting.php';
             RSFormProScripting::compile($template_formdetail, $replace, $with);
         }
         $html = str_replace($replace, $with, $template_formdetail);
     }
     return $html;
 }
示例#2
0
 protected function getValue($item, $field)
 {
     if (in_array($field->FieldName, $this->unescapedFields)) {
         return $item->{$field->FieldName};
     } else {
         // Static header?
         if ($field->componentId < 0 && isset($this->headers[$field->componentId])) {
             $header = $this->headers[$field->componentId];
             if ($header == 'DateSubmitted') {
                 $value = RSFormProHelper::getDate($item->{$header});
             } else {
                 $value = $item->{$header};
             }
         } else {
             // Dynamic header.
             $value = $item->{$field->FieldName};
         }
         return $this->escape($value);
     }
 }
 function getSubmissions()
 {
     $option = JRequest::getVar('option', 'com_rsform');
     if (empty($this->_data)) {
         $formId = $this->getFormId();
         $this->_db->setQuery("SELECT MultipleSeparator, TextareaNewLines FROM #__rsform_forms WHERE FormId='" . $formId . "'");
         $form = $this->_db->loadObject();
         if (empty($form)) {
             return $this->_data;
         }
         $this->_db->setQuery("SELECT c.ComponentTypeId, p.ComponentId, p.PropertyName, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId) WHERE c.FormId='" . $formId . "' AND c.Published='1' AND p.PropertyName IN ('NAME', 'WYSIWYG')");
         $components = $this->_db->loadObjectList();
         $uploadFields = array();
         $multipleFields = array();
         $textareaFields = array();
         foreach ($components as $component) {
             // Upload fields
             if ($component->ComponentTypeId == 9) {
                 $uploadFields[] = $component->PropertyValue;
             } elseif (in_array($component->ComponentTypeId, array(3, 4))) {
                 $multipleFields[] = $component->PropertyValue;
             } elseif ($component->ComponentTypeId == 2) {
                 if ($component->PropertyName == 'WYSIWYG' && $component->PropertyValue == 'NO') {
                     $textareaFields[] = $component->ComponentId;
                 }
             }
         }
         if (!empty($textareaFields)) {
             $this->_db->setQuery("SELECT p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId) WHERE c.ComponentId IN (" . implode(',', $textareaFields) . ")");
             $textareaFields = $this->_db->loadColumn();
         }
         $this->_db->setQuery("SET SQL_BIG_SELECTS=1");
         $this->_db->execute();
         $submissionIds = array();
         $results = $this->_getList($this->_query, $this->getState($option . '.submissions.limitstart'), $this->getState($option . '.submissions.limit'));
         $this->_db->setQuery("SELECT FOUND_ROWS();");
         $this->_total = $this->_db->loadResult();
         foreach ($results as $result) {
             $submissionIds[] = $result->SubmissionId;
             $this->_data[$result->SubmissionId]['FormId'] = $result->FormId;
             $this->_data[$result->SubmissionId]['DateSubmitted'] = RSFormProHelper::getDate($result->DateSubmitted);
             $this->_data[$result->SubmissionId]['UserIp'] = $result->UserIp;
             $this->_data[$result->SubmissionId]['Username'] = $result->Username;
             $this->_data[$result->SubmissionId]['UserId'] = $result->UserId;
             $this->_data[$result->SubmissionId]['Lang'] = $result->Lang;
             $this->_data[$result->SubmissionId]['confirmed'] = $result->confirmed ? JText::_('RSFP_YES') : JText::_('RSFP_NO');
             $this->_data[$result->SubmissionId]['SubmissionValues'] = array();
         }
         if (!empty($submissionIds)) {
             $layout = JRequest::getVar('layout');
             $view = JRequest::getVar('view');
             $must_escape = $view == 'submissions' && $layout == 'default';
             $results = $this->_getList("SELECT * FROM `#__rsform_submission_values` WHERE `SubmissionId` IN (" . implode(',', $submissionIds) . ")");
             foreach ($results as $result) {
                 // Check if this is an upload field
                 if (in_array($result->FieldName, $uploadFields) && !empty($result->FieldValue) && !$this->export) {
                     $result->FieldValue = '<a href="index.php?option=com_rsform&amp;task=submissions.view.file&amp;id=' . $result->SubmissionValueId . '">' . basename($result->FieldValue) . '</a>';
                 } else {
                     // Check if this is a multiple field
                     if (in_array($result->FieldName, $multipleFields)) {
                         $result->FieldValue = str_replace("\n", $form->MultipleSeparator, $result->FieldValue);
                     } elseif ($form->TextareaNewLines && in_array($result->FieldName, $textareaFields)) {
                         if ($must_escape) {
                             $result->FieldValue = RSFormProHelper::htmlEscape($result->FieldValue);
                         }
                         $result->FieldValue = nl2br($result->FieldValue);
                     } elseif ($result->FieldName == '_STATUS') {
                         $result->FieldValue = JText::_('RSFP_PAYPAL_STATUS_' . $result->FieldValue);
                     } elseif ($result->FieldName == '_ANZ_STATUS') {
                         $result->FieldValue = JText::_('RSFP_ANZ_STATUS_' . $result->FieldValue);
                     } else {
                         if ($must_escape) {
                             $result->FieldValue = RSFormProHelper::htmlEscape($result->FieldValue);
                         }
                     }
                 }
                 $this->_data[$result->SubmissionId]['SubmissionValues'][$result->FieldName] = array('Value' => $result->FieldValue, 'Id' => $result->SubmissionValueId);
             }
         }
         unset($results);
     }
     return $this->_data;
 }
 function getTemplate()
 {
     $mainframe = JFactory::getApplication();
     $Itemid = '';
     if ($Itemid = JRequest::getInt('Itemid')) {
         $Itemid = '&Itemid=' . $Itemid;
     }
     $template_module = $this->params->def('template_module', '');
     $template_formdatarow = $this->params->def('template_formdatarow', '');
     $template_formdetail = $this->params->def('template_formdetail', '');
     $formdata = '';
     $has_suffix = $mainframe->getCfg('sef') && $mainframe->getCfg('sef_suffix');
     $layout = JRequest::getVar('layout', 'default');
     if ($layout == 'default') {
         $submissions = $this->getSubmissions();
         $headers = $this->getHeaders();
         $pagination = $this->getPagination();
         $i = 0;
         foreach ($submissions as $SubmissionId => $submission) {
             list($replace, $with) = $this->getReplacements($submission['UserId']);
             $pdf_link = JRoute::_('index.php?option=com_rsform&view=submissions&layout=view&cid=' . $SubmissionId . '&format=pdf' . $Itemid);
             if ($has_suffix) {
                 $pdf_link .= strpos($pdf_link, '?') === false ? '?' : '&';
                 $pdf_link .= 'format=pdf';
             }
             $details_link = JRoute::_('index.php?option=com_rsform&view=submissions&layout=view&cid=' . $SubmissionId . $Itemid);
             $replace = array_merge($replace, array('{global:userip}', '{global:date_added}', '{global:submissionid}', '{global:submission_id}', '{global:counter}', '{details}', '{detailspdf}', '{global:confirmed}', '{details_link}', '{detailspdf_link}'));
             $with = array_merge($with, array($submission['UserIp'], $submission['DateSubmitted'], $SubmissionId, $SubmissionId, $pagination->getRowOffset($i), '<a href="' . $details_link . '">', '<a href="' . $pdf_link . '">', $submission['confirmed'], $details_link, $pdf_link));
             $replace[] = '{_STATUS:value}';
             $with[] = isset($submission['SubmissionValues']['_STATUS']) ? JText::_('RSFP_PAYPAL_STATUS_' . $submission['SubmissionValues']['_STATUS']['Value']) : '';
             foreach ($headers as $header) {
                 if (!isset($submission['SubmissionValues'][$header]['Value'])) {
                     $submission['SubmissionValues'][$header]['Value'] = '';
                 }
                 /* $replace[] = '{'.$header.':value}';
                 			$with[] = $submission['SubmissionValues'][$header]['Value']; */
                 if (!empty($submission['SubmissionValues'][$header]['Path'])) {
                     $replace[] = '{' . $header . ':path}';
                     $with[] = $submission['SubmissionValues'][$header]['Path'];
                 }
             }
             list($replace2, $with2) = RSFormProHelper::getReplacements($SubmissionId, true);
             $replace = array_merge($replace, $replace2);
             $with = array_merge($with, $with2);
             $formdata .= str_replace($replace, $with, $template_formdatarow);
             $i++;
         }
         $html = str_replace('{formdata}', $formdata, $template_module);
     } else {
         $cid = JRequest::getInt('cid');
         $user = JFactory::getUser();
         $userId = $this->params->def('userId', 0);
         if ($userId != 'login' && $userId != 0) {
             $userId = explode(',', $userId);
             JArrayHelper::toInteger($userId);
         }
         $this->_db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . $cid . "'");
         $submission = $this->_db->loadObject();
         if (!$submission || $submission->FormId != $this->params->get('formId') || $userId == 'login' && $submission->UserId != $user->get('id') || is_array($userId) && !in_array($user->get('id'), $userId)) {
             JError::raiseWarning(500, JText::_('ALERTNOTAUTH'));
             $mainframe->redirect(JURI::root());
             return;
         }
         if ($this->params->get('show_confirmed', 0) && !$submission->confirmed) {
             JError::raiseWarning(500, JText::_('ALERTNOTAUTH'));
             $mainframe->redirect(JURI::root());
             return;
         }
         $format = JRequest::getVar('format');
         $pdf_link = JRoute::_('index.php?option=com_rsform&view=submissions&layout=view&cid=' . $cid . '&format=pdf' . $Itemid);
         if ($has_suffix) {
             $pdf_link .= strpos($pdf_link, '?') === false ? '?' : '&';
             $pdf_link .= 'format=pdf';
         }
         $confirmed = $submission->confirmed ? JText::_('RSFP_YES') : JText::_('RSFP_NO');
         list($replace, $with) = RSFormProHelper::getReplacements($cid, true);
         list($replace2, $with2) = $this->getReplacements($submission->UserId);
         $replace = array_merge($replace, $replace2, array('{global:userip}', '{global:date_added}', '{global:submissionid}', '{global:submission_id}', '{detailspdf}', '{global:confirmed}', '{detailspdf_link}'));
         $with = array_merge($with, $with2, array($submission->UserIp, RSFormProHelper::getDate($submission->DateSubmitted), $cid, $cid, '<a href="' . $pdf_link . '">', $confirmed, $pdf_link));
         if ($format == 'pdf' && preg_match_all('#{detailspdf}(.*?){\\/detailspdf}#is', $template_formdetail, $matches)) {
             foreach ($matches[0] as $fullmatch) {
                 $template_formdetail = str_replace($fullmatch, '', $template_formdetail);
             }
         }
         $html = str_replace($replace, $with, $template_formdetail);
     }
     return $html;
 }
 public static function sendSubmissionEmails($SubmissionId, $only_return_replacements = false, $skip_globals = false)
 {
     $db = JFactory::getDBO();
     $u = JUri::getInstance();
     $config = JFactory::getConfig();
     $SubmissionId = (int) $SubmissionId;
     $mainframe = JFactory::getApplication();
     $Itemid = JRequest::getInt('Itemid');
     $Itemid = $Itemid ? '&amp;Itemid=' . $Itemid : '';
     $db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . $SubmissionId . "'");
     $submission = $db->loadObject();
     $submission->values = array();
     $db->setQuery("SELECT FieldName, FieldValue FROM #__rsform_submission_values WHERE SubmissionId='" . $SubmissionId . "'");
     $fields = $db->loadObjectList();
     foreach ($fields as $field) {
         $submission->values[$field->FieldName] = $field->FieldValue;
     }
     unset($fields);
     $formId = $submission->FormId;
     $db->setQuery("SELECT * FROM #__rsform_forms WHERE FormId='" . $formId . "'");
     $form = $db->loadObject();
     $form->MultipleSeparator = str_replace(array('\\n', '\\r', '\\t'), array("\n", "\r", "\t"), $form->MultipleSeparator);
     if (empty($submission->Lang)) {
         if (!empty($form->Lang)) {
             $submission->Lang = $form->Lang;
         } else {
             $lang = JFactory::getLanguage();
             $language = $lang->getDefault();
             $submission->Lang = $language;
         }
         $db->setQuery("UPDATE #__rsform_submissions SET Lang='" . $db->escape($submission->Lang) . "' WHERE SubmissionId='" . $submission->SubmissionId . "'");
         $db->execute();
     }
     $translations = RSFormProHelper::getTranslations('forms', $form->FormId, $submission->Lang);
     if ($translations) {
         foreach ($translations as $field => $value) {
             if (isset($form->{$field})) {
                 $form->{$field} = $value;
             }
         }
     }
     $placeholders = array();
     $values = array();
     $db->setQuery("SELECT c.ComponentTypeId, p.ComponentId, p.PropertyName, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId) WHERE c.FormId='" . $formId . "' AND c.Published='1' AND p.PropertyName IN ('NAME', 'DESCRIPTION', 'CAPTION', 'EMAILATTACH', 'WYSIWYG', 'ITEMS')");
     $components = $db->loadObjectList();
     $properties = array();
     $uploadFields = array();
     $multipleFields = array();
     $textareaFields = array();
     $userEmailUploads = array();
     $adminEmailUploads = array();
     $additionalEmailUploads = array();
     $additionalEmailUploadsIds = array();
     foreach ($components as $component) {
         // Upload fields - grab by NAME so that we can use it later on when checking $_FILES
         if ($component->ComponentTypeId == 9) {
             if ($component->PropertyName == 'EMAILATTACH') {
                 $emailsvalues = $component->PropertyValue;
                 $emailsvalues = trim($emailsvalues) != '' ? explode(',', $emailsvalues) : array();
                 if (!empty($emailsvalues)) {
                     foreach ($emailsvalues as $emailvalue) {
                         if ($emailvalue == 'useremail' || $emailvalue == 'adminemail') {
                             continue;
                         }
                         $additionalEmailUploadsIds[] = $emailvalue;
                     }
                 }
                 $additionalEmailUploadsIds = array_unique($additionalEmailUploadsIds);
                 if (!empty($additionalEmailUploadsIds)) {
                     foreach ($additionalEmailUploadsIds as $additionalEmailUploadsId) {
                         if (in_array($additionalEmailUploadsId, $emailsvalues)) {
                             $additionalEmailUploads[$additionalEmailUploadsId][] = $component->ComponentId;
                         }
                     }
                 }
             }
             if ($component->PropertyName == 'NAME') {
                 $uploadFields[] = $component->PropertyValue;
             }
             if ($component->PropertyName == 'EMAILATTACH' && !empty($component->PropertyValue)) {
                 $emailvalues = explode(',', $component->PropertyValue);
                 if (in_array('useremail', $emailvalues)) {
                     $userEmailUploads[] = $component->ComponentId;
                     //continue;
                 }
                 if (in_array('adminemail', $emailvalues)) {
                     $adminEmailUploads[] = $component->ComponentId;
                     //continue;
                 }
             }
         } elseif (in_array($component->ComponentTypeId, array(3, 4))) {
             if ($component->PropertyName == 'NAME') {
                 $multipleFields[] = $component->ComponentId;
             }
         } elseif ($component->ComponentTypeId == 2) {
             if ($component->PropertyName == 'WYSIWYG' && $component->PropertyValue == 'NO') {
                 $textareaFields[] = $component->ComponentId;
             }
         }
         $properties[$component->ComponentId][$component->PropertyName] = $component->PropertyValue;
     }
     // language
     $translations = RSFormProHelper::getTranslations('properties', $formId, $submission->Lang);
     foreach ($properties as $componentId => $componentProperties) {
         foreach ($componentProperties as $property => $value) {
             $reference_id = $componentId . '.' . $property;
             if (isset($translations[$reference_id])) {
                 $componentProperties[$property] = $translations[$reference_id];
             }
         }
         $properties[$componentId] = $componentProperties;
     }
     $secret = $config->get('secret');
     foreach ($properties as $ComponentId => $property) {
         // {component:caption}
         $placeholders[] = '{' . $property['NAME'] . ':caption}';
         $values[] = isset($property['CAPTION']) ? $property['CAPTION'] : '';
         // {component:description}
         $placeholders[] = '{' . $property['NAME'] . ':description}';
         $values[] = isset($property['DESCRIPTION']) ? $property['DESCRIPTION'] : '';
         // {component:name}
         $placeholders[] = '{' . $property['NAME'] . ':name}';
         $values[] = $property['NAME'];
         // {component:price}
         $placeholders[] = '{' . $property['NAME'] . ':price}';
         $values[] = RSFormProHelper::getComponentPrice($property, $submission);
         // {component:value}
         $placeholders[] = '{' . $property['NAME'] . ':value}';
         $value = '';
         if (isset($submission->values[$property['NAME']])) {
             $value = $submission->values[$property['NAME']];
             // Check if this is an upload field
             if (in_array($property['NAME'], $uploadFields)) {
                 $value = '<a href="' . JURI::root() . 'index.php?option=com_rsform&amp;task=submissions.view.file&amp;hash=' . md5($submission->SubmissionId . $secret . $property['NAME']) . $Itemid . '">' . basename($submission->values[$property['NAME']]) . '</a>';
             } elseif (in_array($ComponentId, $multipleFields)) {
                 $value = str_replace("\n", $form->MultipleSeparator, $value);
             } elseif ($form->TextareaNewLines && in_array($ComponentId, $textareaFields)) {
                 $value = nl2br($value);
             }
         }
         $values[] = $value;
         if (isset($property['ITEMS'])) {
             $placeholders[] = '{' . $property['NAME'] . ':text}';
             if (isset($submission->values[$property['NAME']])) {
                 $value = $submission->values[$property['NAME']];
                 $all_values = explode("\n", $value);
                 $all_texts = array();
                 $items = RSFormProHelper::explode(RSFormProHelper::isCode($property['ITEMS']));
                 $special = array('[c]', '[g]', '[d]');
                 foreach ($all_values as $v => $value) {
                     $all_texts[$v] = $value;
                     foreach ($items as $item) {
                         $item = str_replace($special, '', $item);
                         @(list($item_val, $item_text) = explode("|", $item, 2));
                         if ($item_text && $item_val == $value) {
                             $all_texts[$v] = $item_text;
                             break;
                         }
                     }
                 }
                 if ($all_texts) {
                     $values[] = implode($form->MultipleSeparator, $all_texts);
                 } else {
                     $values[] = $value;
                 }
             } else {
                 $values[] = '';
             }
         }
         // {component:path}
         // {component:localpath}
         // {component:filename}
         if (in_array($property['NAME'], $uploadFields)) {
             $placeholders[] = '{' . $property['NAME'] . ':path}';
             $placeholders[] = '{' . $property['NAME'] . ':localpath}';
             $placeholders[] = '{' . $property['NAME'] . ':filename}';
             if (isset($submission->values[$property['NAME']])) {
                 $filepath = $submission->values[$property['NAME']];
                 $filepath = substr_replace($filepath, JURI::root(), 0, strlen(JPATH_SITE) + 1);
                 $filepath = str_replace(array('\\', '\\/', '//\\'), '/', $filepath);
                 $values[] = $filepath;
                 $values[] = $submission->values[$property['NAME']];
                 $values[] = basename($submission->values[$property['NAME']]);
             } else {
                 $values[] = '';
                 $values[] = '';
                 $values[] = '';
             }
         }
     }
     $placeholders[] = '{_STATUS:value}';
     $values[] = isset($submission->values['_STATUS']) ? JText::_('RSFP_PAYPAL_STATUS_' . $submission->values['_STATUS']) : '';
     $placeholders[] = '{_ANZ_STATUS:value}';
     $values[] = isset($submission->values['_ANZ_STATUS']) ? JText::_('RSFP_ANZ_STATUS_' . $submission->values['_ANZ_STATUS']) : '';
     $user = JFactory::getUser($submission->UserId);
     if (empty($user->id)) {
         $user = JFactory::getUser(0);
     }
     $root = $mainframe->isAdmin() ? JURI::root() : $u->toString(array('scheme', 'host', 'port'));
     $confirmation_hash = md5($submission->SubmissionId . $formId . $submission->DateSubmitted);
     $hash_link = 'index.php?option=com_rsform&task=confirm&hash=' . $confirmation_hash;
     $confirmation = $root . ($mainframe->isAdmin() ? $hash_link : JRoute::_($hash_link));
     if (!$skip_globals) {
         array_push($placeholders, '{global:username}', '{global:userid}', '{global:useremail}', '{global:fullname}', '{global:userip}', '{global:date_added}', '{global:sitename}', '{global:siteurl}', '{global:confirmation}', '{global:submissionid}', '{global:submission_id}');
         array_push($values, $user->username, $user->id, $user->email, $user->name, $submission->UserIp, RSFormProHelper::getDate($submission->DateSubmitted), $config->get('sitename'), JURI::root(), $confirmation, $submission->SubmissionId, $submission->SubmissionId);
     }
     $mainframe->triggerEvent('rsfp_onAfterCreatePlaceholders', array(array('form' => &$form, 'placeholders' => &$placeholders, 'values' => &$values, 'submission' => $submission)));
     if ($only_return_replacements) {
         return array($placeholders, $values);
     }
     // RSForm! Pro Scripting - User Email Text
     // performance check
     if (strpos($form->UserEmailText, '{if ') !== false && strpos($form->UserEmailText, '{/if}') !== false) {
         require_once dirname(__FILE__) . '/scripting.php';
         RSFormProScripting::compile($form->UserEmailText, $placeholders, $values);
     }
     $userEmail = array('to' => str_replace($placeholders, $values, $form->UserEmailTo), 'cc' => str_replace($placeholders, $values, $form->UserEmailCC), 'bcc' => str_replace($placeholders, $values, $form->UserEmailBCC), 'from' => str_replace($placeholders, $values, $form->UserEmailFrom), 'replyto' => str_replace($placeholders, $values, $form->UserEmailReplyTo), 'fromName' => str_replace($placeholders, $values, $form->UserEmailFromName), 'text' => str_replace($placeholders, $values, $form->UserEmailText), 'subject' => str_replace($placeholders, $values, $form->UserEmailSubject), 'mode' => $form->UserEmailMode, 'files' => array());
     // user cc
     if (strpos($userEmail['cc'], ',') !== false) {
         $userEmail['cc'] = explode(',', $userEmail['cc']);
     }
     // user bcc
     if (strpos($userEmail['bcc'], ',') !== false) {
         $userEmail['bcc'] = explode(',', $userEmail['bcc']);
     }
     jimport('joomla.filesystem.file');
     $file = str_replace($placeholders, $values, $form->UserEmailAttachFile);
     if ($form->UserEmailAttach && JFile::exists($file)) {
         $userEmail['files'][] = $file;
     }
     // Need to attach files
     // User Email
     foreach ($userEmailUploads as $componentId) {
         $name = $properties[$componentId]['NAME'];
         if (!empty($submission->values[$name])) {
             $userEmail['files'][] = $submission->values[$name];
         }
     }
     // RSForm! Pro Scripting - Admin Email Text
     // performance check
     if (strpos($form->AdminEmailText, '{if ') !== false && strpos($form->AdminEmailText, '{/if}') !== false) {
         require_once dirname(__FILE__) . '/scripting.php';
         RSFormProScripting::compile($form->AdminEmailText, $placeholders, $values);
     }
     $adminEmail = array('to' => str_replace($placeholders, $values, $form->AdminEmailTo), 'cc' => str_replace($placeholders, $values, $form->AdminEmailCC), 'bcc' => str_replace($placeholders, $values, $form->AdminEmailBCC), 'from' => str_replace($placeholders, $values, $form->AdminEmailFrom), 'replyto' => str_replace($placeholders, $values, $form->AdminEmailReplyTo), 'fromName' => str_replace($placeholders, $values, $form->AdminEmailFromName), 'text' => str_replace($placeholders, $values, $form->AdminEmailText), 'subject' => str_replace($placeholders, $values, $form->AdminEmailSubject), 'mode' => $form->AdminEmailMode, 'files' => array());
     // admin cc
     if (strpos($adminEmail['cc'], ',') !== false) {
         $adminEmail['cc'] = explode(',', $adminEmail['cc']);
     }
     // admin bcc
     if (strpos($adminEmail['bcc'], ',') !== false) {
         $adminEmail['bcc'] = explode(',', $adminEmail['bcc']);
     }
     // Admin Email
     foreach ($adminEmailUploads as $componentId) {
         $name = $properties[$componentId]['NAME'];
         if (!empty($submission->values[$name])) {
             $adminEmail['files'][] = $submission->values[$name];
         }
     }
     $mainframe->triggerEvent('rsfp_beforeUserEmail', array(array('form' => &$form, 'placeholders' => &$placeholders, 'values' => &$values, 'submissionId' => $SubmissionId, 'userEmail' => &$userEmail)));
     // Script called before the User Email is sent.
     eval($form->UserEmailScript);
     // mail users
     if ($userEmail['to']) {
         $recipients = explode(',', $userEmail['to']);
         RSFormProHelper::sendMail($userEmail['from'], $userEmail['fromName'], $recipients, $userEmail['subject'], $userEmail['text'], $userEmail['mode'], !empty($userEmail['cc']) ? $userEmail['cc'] : null, !empty($userEmail['bcc']) ? $userEmail['bcc'] : null, $userEmail['files'], !empty($userEmail['replyto']) ? $userEmail['replyto'] : '');
     }
     $mainframe->triggerEvent('rsfp_beforeAdminEmail', array(array('form' => &$form, 'placeholders' => &$placeholders, 'values' => &$values, 'submissionId' => $SubmissionId, 'adminEmail' => &$adminEmail)));
     // Script called before the Admin Email is sent.
     eval($form->AdminEmailScript);
     //mail admins
     if ($adminEmail['to']) {
         $recipients = explode(',', $adminEmail['to']);
         RSFormProHelper::sendMail($adminEmail['from'], $adminEmail['fromName'], $recipients, $adminEmail['subject'], $adminEmail['text'], $adminEmail['mode'], !empty($adminEmail['cc']) ? $adminEmail['cc'] : null, !empty($adminEmail['bcc']) ? $adminEmail['bcc'] : null, $adminEmail['files'], !empty($adminEmail['replyto']) ? $adminEmail['replyto'] : '');
     }
     //additional emails
     $db->setQuery("SELECT * FROM #__rsform_emails WHERE `type` = 'additional' AND `formId` = " . $formId . " AND `from` != ''");
     if ($emails = $db->loadObjectList()) {
         $etranslations = RSFormProHelper::getTranslations('emails', $formId, $submission->Lang);
         foreach ($emails as $email) {
             if (isset($etranslations[$email->id . '.fromname'])) {
                 $email->fromname = $etranslations[$email->id . '.fromname'];
             }
             if (isset($etranslations[$email->id . '.subject'])) {
                 $email->subject = $etranslations[$email->id . '.subject'];
             }
             if (isset($etranslations[$email->id . '.message'])) {
                 $email->message = $etranslations[$email->id . '.message'];
             }
             if (empty($email->fromname) || empty($email->subject) || empty($email->message)) {
                 continue;
             }
             // RSForm! Pro Scripting - Additional Email Text
             // performance check
             if (strpos($email->message, '{if ') !== false && strpos($email->message, '{/if}') !== false) {
                 require_once dirname(__FILE__) . '/scripting.php';
                 RSFormProScripting::compile($email->message, $placeholders, $values);
             }
             $additionalEmail = array('to' => str_replace($placeholders, $values, $email->to), 'cc' => str_replace($placeholders, $values, $email->cc), 'bcc' => str_replace($placeholders, $values, $email->bcc), 'from' => str_replace($placeholders, $values, $email->from), 'replyto' => str_replace($placeholders, $values, $email->replyto), 'fromName' => str_replace($placeholders, $values, $email->fromname), 'text' => str_replace($placeholders, $values, $email->message), 'subject' => str_replace($placeholders, $values, $email->subject), 'mode' => $email->mode, 'files' => array());
             if (!empty($additionalEmailUploads)) {
                 foreach ($additionalEmailUploads as $additionalEmailId => $additionalEmailUpload) {
                     if ($additionalEmailId == $email->id) {
                         foreach ($additionalEmailUpload as $componentId) {
                             $name = $properties[$componentId]['NAME'];
                             if (!empty($submission->values[$name])) {
                                 $additionalEmail['files'][] = $submission->values[$name];
                             }
                         }
                     }
                 }
             }
             // additional cc
             if (strpos($additionalEmail['cc'], ',') !== false) {
                 $additionalEmail['cc'] = explode(',', $additionalEmail['cc']);
             }
             // additional bcc
             if (strpos($additionalEmail['bcc'], ',') !== false) {
                 $additionalEmail['bcc'] = explode(',', $additionalEmail['bcc']);
             }
             $mainframe->triggerEvent('rsfp_beforeAdditionalEmail', array(array('form' => &$form, 'placeholders' => &$placeholders, 'values' => &$values, 'submissionId' => $SubmissionId, 'additionalEmail' => &$additionalEmail)));
             eval($form->AdditionalEmailsScript);
             // mail users
             if ($additionalEmail['to']) {
                 $recipients = explode(',', $additionalEmail['to']);
                 RSFormProHelper::sendMail($additionalEmail['from'], $additionalEmail['fromName'], $recipients, $additionalEmail['subject'], $additionalEmail['text'], $additionalEmail['mode'], !empty($additionalEmail['cc']) ? $additionalEmail['cc'] : null, !empty($additionalEmail['bcc']) ? $additionalEmail['bcc'] : null, $additionalEmail['files'], !empty($additionalEmail['replyto']) ? $additionalEmail['replyto'] : '');
             }
         }
     }
     return array($placeholders, $values);
 }
示例#6
0
文件: edit.php 项目: ForAEdesWeb/AEW3
			</td>
			<td>
				<?php 
    if ($header == 'confirmed') {
        ?>
				<?php 
        echo JHTML::_('select.booleanlist', 'formStatic[' . $header . ']', 'class="inputbox"', $this->staticFields->{$header});
        ?>
				<?php 
    } else {
        ?>
				<input class="rs_inp rs_80" type="text" name="formStatic[<?php 
        echo $header;
        ?>
]" value="<?php 
        echo $header == 'DateSubmitted' ? RSFormProHelper::getDate($this->staticFields->{$header}) : $this->staticFields->{$header};
        ?>
" size="105" />
				<?php 
    }
    ?>
			</td>
		</tr>
		<?php 
}
?>
		<?php 
foreach ($this->fields as $field) {
    ?>
		<tr>
			<td width="200" style="width: 200px;" align="right" class="key">
示例#7
0
 public function getTemplate()
 {
     $cid = $this->_app->input->getInt('id', 0);
     $format = $this->_app->input->get('format');
     $user = JFactory::getUser();
     $userId = $this->params->def('userId', 0);
     $directory = $this->getDirectory();
     $template = $directory->ViewLayout;
     if ($userId != 'login' && $userId != 0) {
         $userId = explode(',', $userId);
         JArrayHelper::toInteger($userId);
     }
     // Grab submission
     $this->_db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . $cid . "'");
     $submission = $this->_db->loadObject();
     // Submission doesn't exist
     if (!$submission) {
         JError::raiseWarning(500, JText::sprintf('RSFP_SUBMISSION_DOES_NOT_EXIST', $cid));
         return $this->_app->redirect(JURI::root());
     }
     // Submission doesn't belong to the configured form ID OR
     // can view only own submissions and not his own OR
     // can view only specified user IDs and this doesn't belong to any of the IDs
     if ($submission->FormId != $this->params->get('formId') || $userId == 'login' && $submission->UserId != $user->get('id') || is_array($userId) && !in_array($user->get('id'), $userId)) {
         JError::raiseWarning(500, JText::sprintf('RSFP_SUBMISSION_NOT_ALLOWED', $cid));
         return $this->_app->redirect(JURI::root());
     }
     if ($this->params->get('show_confirmed', 0) && !$submission->confirmed) {
         JError::raiseWarning(500, JText::sprintf('RSFP_SUBMISSION_NOT_CONFIRMED', $cid));
         return $this->_app->redirect(JURI::root());
     }
     $confirmed = $submission->confirmed ? JText::_('RSFP_YES') : JText::_('RSFP_NO');
     list($replace, $with) = RSFormProHelper::getReplacements($cid, true);
     list($replace2, $with2) = $this->getReplacements($submission->UserId);
     $replace = array_merge($replace, $replace2, array('{global:userip}', '{global:date_added}', '{global:submissionid}', '{global:submission_id}', '{global:confirmed}', '{global:lang}'));
     $with = array_merge($with, $with2, array($submission->UserIp, RSFormProHelper::getDate($submission->DateSubmitted), $cid, $cid, $confirmed, $submission->Lang));
     if ($format == 'pdf') {
         if (strpos($template, ':path}') !== false) {
             $template = str_replace(':path}', ':localpath}', $template);
         }
     }
     if (strpos($template, '{/if}') !== false) {
         require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/scripting.php';
         RSFormProScripting::compile($template, $replace, $with);
     }
     $detailsLayout = str_replace($replace, $with, $template);
     eval($directory->DetailsScript);
     return $detailsLayout;
 }