当前位置: 首页>>代码示例>>PHP>>正文


PHP RSFormProHelper::validateForm方法代码示例

本文整理汇总了PHP中RSFormProHelper::validateForm方法的典型用法代码示例。如果您正苦于以下问题:PHP RSFormProHelper::validateForm方法的具体用法?PHP RSFormProHelper::validateForm怎么用?PHP RSFormProHelper::validateForm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RSFormProHelper的用法示例。


在下文中一共展示了RSFormProHelper::validateForm方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ajaxValidate

 function ajaxValidate()
 {
     $form = JRequest::getVar('form');
     $formId = (int) @$form['formId'];
     $this->_db->setQuery("SELECT ComponentId, ComponentTypeId FROM #__rsform_components WHERE `FormId`='" . $formId . "' AND `Published`='1' ORDER BY `Order`");
     $components = $this->_db->loadObjectList();
     $page = JRequest::getInt('page');
     if ($page) {
         $current_page = 1;
         foreach ($components as $i => $component) {
             if ($current_page != $page) {
                 unset($components[$i]);
             }
             if ($component->ComponentTypeId == 41) {
                 $current_page++;
             }
         }
     }
     $removeUploads = array();
     $removeRecaptcha = array();
     $formComponents = array();
     foreach ($components as $component) {
         $formComponents[] = $component->ComponentId;
         if ($component->ComponentTypeId == 9) {
             $removeUploads[] = $component->ComponentId;
         }
         if ($component->ComponentTypeId == 24) {
             $removeRecaptcha[] = $component->ComponentId;
         }
     }
     echo implode(',', $formComponents);
     echo "\n";
     $invalid = RSFormProHelper::validateForm($formId);
     if (count($invalid)) {
         foreach ($invalid as $i => $componentId) {
             if (in_array($componentId, $removeUploads) || in_array($componentId, $removeRecaptcha)) {
                 unset($invalid[$i]);
             }
         }
         $invalidComponents = array_intersect($formComponents, $invalid);
         echo implode(',', $invalidComponents);
     }
     if (isset($invalidComponents)) {
         echo "\n";
         $pages = RSFormProHelper::componentExists($formId, 41);
         $pages = count($pages);
         if ($pages && !$page) {
             $first = reset($invalidComponents);
             $current_page = 1;
             foreach ($components as $i => $component) {
                 if ($component->ComponentId == $first) {
                     break;
                 }
                 if ($component->ComponentTypeId == 41) {
                     $current_page++;
                 }
             }
             echo $current_page;
             echo "\n";
             echo $pages;
         }
     }
     jexit();
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:64,代码来源:controller.php

示例2: getEditFields

 public static function getEditFields($cid)
 {
     $db = JFactory::getDbo();
     $return = array();
     $values = JFactory::getApplication()->input->get('form', array(), 'array');
     $pattern = '#\\[p(.*?)\\]#is';
     $db->setQuery("SELECT * FROM #__rsform_submissions WHERE SubmissionId='" . (int) $cid . "'");
     $submission = $db->loadObject();
     if (empty($submission)) {
         $mainframe = JFactory::getApplication();
         $mainframe->redirect(JURI::root());
         return $return;
     }
     $validation = !empty($values) ? RSFormProHelper::validateForm($submission->FormId, 'directory') : array();
     $formFields = RSFormProHelper::getDirectoryFields($submission->FormId);
     $editable = array();
     foreach ($formFields as $formField) {
         if ($formField->editable) {
             $editable[] = $formField->FieldName;
         }
     }
     $db->setQuery("SELECT FieldName, FieldValue FROM #__rsform_submission_values WHERE SubmissionId='" . (int) $cid . "'");
     $fields = $db->loadObjectList();
     foreach ($fields as $field) {
         $submission->values[$field->FieldName] = $field->FieldValue;
     }
     unset($fields);
     $db->setQuery("SELECT p.PropertyValue, ct.ComponentTypeName, c.ComponentId FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (p.ComponentId=c.ComponentId) LEFT JOIN #__rsform_component_types ct ON (c.ComponentTypeId=ct.ComponentTypeId) WHERE c.FormId='" . $submission->FormId . "' AND c.Published='1' AND p.PropertyName='NAME' ORDER BY `Order`");
     $fields = $db->loadObjectList();
     if (empty($fields)) {
         return $return;
     }
     $componentIds = array();
     foreach ($fields as $field) {
         $componentIds[] = $field->ComponentId;
     }
     $properties = RSFormProHelper::getComponentProperties($componentIds);
     $fields = RSFormProHelper::sortFields($fields, $editable);
     foreach ($fields as $field) {
         if (!in_array($field->PropertyValue, $editable)) {
             continue;
         }
         $invalid = !empty($validation) && in_array($field->ComponentId, $validation) ? ' rsform-error' : '';
         $data = $properties[$field->ComponentId];
         $new_field = array();
         $new_field[0] = !empty($data['CAPTION']) ? $data['CAPTION'] : $field->PropertyValue;
         $new_field[2] = isset($data['REQUIRED']) && $data['REQUIRED'] == 'YES' ? '<strong class="formRequired">(*)</strong>' : '';
         $new_field[3] = $field->PropertyValue;
         $name = $field->PropertyValue;
         if (isset($values[$field->PropertyValue])) {
             $value = $values[$field->PropertyValue];
         } else {
             $value = isset($submission->values[$field->PropertyValue]) ? $submission->values[$field->PropertyValue] : '';
         }
         if ($data['NAME'] == 'RSEProPayment') {
             $field->ComponentTypeName = 'rsepropayment';
         }
         switch ($field->ComponentTypeName) {
             // skip this field for now, no need to edit it
             case 'freeText':
                 continue 2;
                 break;
             default:
                 if (strpos($value, "\n") !== false || strpos($value, "\r") !== false) {
                     $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>';
                 } else {
                     $new_field[1] = '<input class="rs_inp rs_80' . $invalid . '" type="text" name="form[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />';
                 }
                 break;
             case 'textArea':
                 if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
                     $new_field[1] = RSFormProHelper::WYSIWYG('form[' . $name . ']', RSFormProHelper::htmlEscape($value), '', 600, 100, 60, 10);
                 } else {
                     $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>';
                 }
                 break;
             case 'radioGroup':
             case 'checkboxGroup':
             case 'selectList':
                 if ($field->ComponentTypeName == 'radioGroup') {
                     $data['SIZE'] = 0;
                     $data['MULTIPLE'] = 'NO';
                 } elseif ($field->ComponentTypeName == 'checkboxGroup') {
                     $data['SIZE'] = 5;
                     $data['MULTIPLE'] = 'YES';
                 }
                 $value = !empty($values) ? $value : RSFormProHelper::explode($value);
                 $items = RSFormProHelper::isCode($data['ITEMS']);
                 $items = RSFormProHelper::explode($items);
                 $options = array();
                 foreach ($items as $item) {
                     if (preg_match($pattern, $item, $match)) {
                         $item = preg_replace($pattern, '', $item);
                     }
                     // <OPTGROUP>
                     if (preg_match('/\\[g\\]/', $item)) {
                         $item = str_replace('[g]', '', $item);
                         $optgroup = new stdClass();
                         $optgroup->value = '<OPTGROUP>';
                         $optgroup->text = $item;
//.........这里部分代码省略.........
开发者ID:renekreijveld,项目名称:rsformpro-bootstrapped,代码行数:101,代码来源:rsform.php

示例3: ajaxValidate

 function ajaxValidate()
 {
     $form = JRequest::getVar('form');
     $formId = (int) @$form['formId'];
     $this->_db->setQuery("SELECT ComponentId, ComponentTypeId FROM #__rsform_components WHERE `FormId`='" . $formId . "' AND `Published`='1' ORDER BY `Order`");
     $components = $this->_db->loadObjectList();
     $page = JRequest::getInt('page');
     if ($page) {
         $current_page = 1;
         foreach ($components as $i => $component) {
             if ($current_page != $page) {
                 unset($components[$i]);
             }
             if ($component->ComponentTypeId == 41) {
                 $current_page++;
             }
         }
     }
     $removeUploads = array();
     $formComponents = array();
     foreach ($components as $component) {
         $formComponents[] = $component->ComponentId;
         if ($component->ComponentTypeId == 9) {
             $removeUploads[] = $component->ComponentId;
         }
     }
     echo implode(',', $formComponents);
     echo "\n";
     $invalid = RSFormProHelper::validateForm($formId);
     //Trigger Event - onBeforeFormValidation
     $mainframe = JFactory::getApplication();
     $post = JRequest::get('post', JREQUEST_ALLOWRAW);
     $mainframe->triggerEvent('rsfp_f_onBeforeFormValidation', array(array('invalid' => &$invalid, 'formId' => $formId, 'post' => &$post)));
     if (count($invalid)) {
         foreach ($invalid as $i => $componentId) {
             if (in_array($componentId, $removeUploads)) {
                 unset($invalid[$i]);
             }
         }
         $invalidComponents = array_intersect($formComponents, $invalid);
         echo implode(',', $invalidComponents);
     }
     if (isset($invalidComponents)) {
         echo "\n";
         $pages = RSFormProHelper::componentExists($formId, 41);
         $pages = count($pages);
         if ($pages && !$page) {
             $first = reset($invalidComponents);
             $current_page = 1;
             foreach ($components as $i => $component) {
                 if ($component->ComponentId == $first) {
                     break;
                 }
                 if ($component->ComponentTypeId == 41) {
                     $current_page++;
                 }
             }
             echo $current_page;
             echo "\n";
             echo $pages;
         }
     }
     jexit();
 }
开发者ID:alvarovladimir,项目名称:messermeister_ab_rackservers,代码行数:64,代码来源:controller.php

示例4: RSvalidateForm

function RSvalidateForm($formId)
{
    return RSFormProHelper::validateForm($formId);
}
开发者ID:jtresca,项目名称:nysurveyor,代码行数:4,代码来源:legacy.php

示例5: getEditFields

 public static function getEditFields($cid)
 {
     $db = JFactory::getDbo();
     $return = array();
     $values = JFactory::getApplication()->input->get('form', array(), 'array');
     $pattern = '#\\[p(.*?)\\]#is';
     // Load submission
     $query = $db->getQuery(true);
     $query->select('*')->from($db->qn('#__rsform_submissions'))->where($db->qn('SubmissionId') . '=' . $db->q($cid));
     $submission = $db->setQuery($query)->loadObject();
     if (empty($submission)) {
         return $return;
     }
     $submission->DateSubmitted = JHtml::_('date', $submission->DateSubmitted, 'Y-m-d H:i:s');
     // Get submission values
     $submission->values = array();
     $query->clear()->select($db->qn('FieldName'))->select($db->qn('FieldValue'))->from($db->qn('#__rsform_submission_values'))->where($db->qn('SubmissionId') . '=' . $db->q($cid));
     if ($values = $db->setQuery($query)->loadObjectList()) {
         foreach ($values as $value) {
             $submission->values[$value->FieldName] = $value->FieldValue;
         }
         unset($values);
     }
     $validation = !empty($values) ? RSFormProHelper::validateForm($submission->FormId, 'directory') : array();
     $formFields = self::getDirectoryFields($submission->FormId);
     $headers = self::getDirectoryStaticHeaders();
     $query = $db->getQuery(true);
     $query->select($db->qn('ct.ComponentTypeName', 'type'))->select($db->qn('c.ComponentId'))->from($db->qn('#__rsform_components', 'c'))->join('left', $db->qn('#__rsform_component_types', 'ct') . ' ON (' . $db->qn('c.ComponentTypeId') . '=' . $db->qn('ct.ComponentTypeId') . ')')->where($db->qn('c.FormId') . '=' . $db->q($submission->FormId))->where($db->qn('c.Published') . '=' . $db->q(1));
     $componentTypes = $db->setQuery($query)->loadObjectList('ComponentId');
     $componentIds = array();
     foreach ($formFields as $formField) {
         if ($formField->FieldId > 0) {
             $componentIds[] = $formField->FieldId;
         }
         // Assign the type
         $formField->type = '';
         if ($formField->FieldId < 0) {
             $formField->type = 'static';
         } elseif (isset($componentTypes[$formField->FieldId])) {
             $formField->type = $componentTypes[$formField->FieldId]->type;
         }
         // For convenience...
         $formField->id = $formField->FieldId;
         $formField->name = $formField->FieldName;
     }
     $properties = RSFormProHelper::getComponentProperties($componentIds);
     foreach ($formFields as $field) {
         if (!$field->editable) {
             continue;
         }
         $invalid = !empty($validation) && in_array($field->id, $validation) ? ' rsform-error' : '';
         $data = $field->id > 0 ? $properties[$field->id] : array('NAME' => $field->name);
         $new_field = array();
         $new_field[0] = !empty($data['CAPTION']) ? $data['CAPTION'] : $field->name;
         $new_field[2] = isset($data['REQUIRED']) && $data['REQUIRED'] == 'YES' ? '<strong class="formRequired">(*)</strong>' : '';
         $new_field[3] = $field->name;
         $name = $field->name;
         if ($field->type != 'static') {
             if (isset($values[$field->name])) {
                 $value = $values[$field->name];
             } else {
                 $value = isset($submission->values[$field->name]) ? $submission->values[$field->name] : '';
             }
         } else {
             $value = isset($submission->{$field->name}) ? $submission->{$field->name} : '';
         }
         if ($data['NAME'] == 'RSEProPayment') {
             $field->type = 'rsepropayment';
         }
         switch ($field->type) {
             case 'static':
                 $new_field[0] = JText::_('RSFP_' . $field->name);
                 // Show a dropdown for yes/no
                 if ($field->name == 'confirmed') {
                     $options = array(JHtml::_('select.option', 0, JText::_('RSFP_NO')), JHtml::_('select.option', 1, JText::_('RSFP_YES')));
                     $new_field[1] = JHTML::_('select.genericlist', $options, 'formStatic[confirmed]', null, 'value', 'text', $value);
                 } else {
                     $new_field[1] = '<input class="rs_inp rs_80" type="text" name="formStatic[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />';
                 }
                 break;
                 // skip this field for now, no need to edit it
             // skip this field for now, no need to edit it
             case 'freeText':
                 continue 2;
                 break;
             default:
                 if (strpos($value, "\n") !== false || strpos($value, "\r") !== false) {
                     $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>';
                 } else {
                     $new_field[1] = '<input class="rs_inp rs_80' . $invalid . '" type="text" name="form[' . $name . ']" value="' . RSFormProHelper::htmlEscape($value) . '" />';
                 }
                 break;
             case 'textArea':
                 if (isset($data['WYSIWYG']) && $data['WYSIWYG'] == 'YES') {
                     $new_field[1] = RSFormProHelper::WYSIWYG('form[' . $name . ']', RSFormProHelper::htmlEscape($value), '', 600, 100, 60, 10);
                 } else {
                     $new_field[1] = '<textarea style="width: 95%" class="rs_textarea' . $invalid . '" rows="10" cols="60" name="form[' . $name . ']">' . RSFormProHelper::htmlEscape($value) . '</textarea>';
                 }
                 break;
             case 'radioGroup':
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:rsform.php

示例6: save

 public function save()
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $cid = JRequest::getInt('id');
     $form = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
     $static = JRequest::getVar('formStatic', array(), 'post', 'none', JREQUEST_ALLOWRAW);
     $formId = JRequest::getInt('formId');
     $files = JRequest::getVar('form', array(), 'files', 'none', JREQUEST_ALLOWRAW);
     $validation = RSFormProHelper::validateForm($formId, 'directory', $cid);
     if (!empty($validation)) {
         return false;
     }
     $formFields = RSFormProHelper::getDirectoryFields($formId);
     $headers = RSFormProHelper::getDirectoryStaticHeaders();
     $staticFields = array();
     $allowed = array();
     foreach ($formFields as $field) {
         if ($field->editable) {
             if ($field->componentId < 0 && isset($headers[$field->componentId])) {
                 $staticFields[] = $field->FieldName;
             } else {
                 $allowed[] = $field->FieldName;
             }
         }
     }
     //Trigger Event - onBeforeDirectorySave
     $this->_app->triggerEvent('rsfp_f_onBeforeDirectorySave', array(array('SubmissionId' => &$cid, 'formId' => $formId, 'post' => &$form)));
     // Handle file uploads first
     if (!empty($files['error'])) {
         foreach ($files['error'] as $field => $error) {
             if (!in_array($field, $allowed) || $error) {
                 continue;
             }
             // The above $validation should suffice
             $this->_db->setQuery("SELECT FieldValue FROM #__rsform_submission_values WHERE FieldName='" . $this->_db->escape($field) . "' AND SubmissionId='" . $cid . "' LIMIT 1");
             $original = $this->_db->loadResult();
             // Prefix
             $componentId = RSFormProHelper::getComponentId($field, $formId);
             $data = RSFormProHelper::getComponentProperties($componentId);
             $prefix = uniqid('') . '-';
             if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
                 $prefix = RSFormProHelper::isCode($data['PREFIX']);
             }
             // Path
             $realpath = realpath($data['DESTINATION'] . DIRECTORY_SEPARATOR);
             if (substr($realpath, -1) != DIRECTORY_SEPARATOR) {
                 $realpath .= DIRECTORY_SEPARATOR;
             }
             // Filename
             $file = $realpath . $prefix . $files['name'][$field];
             // Upload File
             if (JFile::upload($files['tmp_name'][$field], $file) && $file != $original) {
                 // Remove the original file to save up space
                 if (file_exists($original) && is_file($original)) {
                     JFile::delete($original);
                 }
                 // Add to db (submission value)
                 $form[$field] = $file;
             }
         }
     }
     // Update fields
     foreach ($form as $field => $value) {
         if (!in_array($field, $allowed)) {
             continue;
         }
         if (is_array($value)) {
             $value = implode("\n", $value);
         }
         // Dynamic field - update value.
         $this->_db->setQuery("SELECT SubmissionValueId, FieldValue FROM #__rsform_submission_values WHERE FieldName='" . $this->_db->escape($field) . "' AND SubmissionId='" . $cid . "' LIMIT 1");
         $original = $this->_db->loadObject();
         if (!$original) {
             $this->_db->setQuery("INSERT INTO #__rsform_submission_values SET FormId='" . $formId . "', SubmissionId='" . $cid . "', FieldName='" . $this->_db->escape($field) . "', FieldValue='" . $this->_db->escape($value) . "'");
             $this->_db->execute();
         } else {
             // Update only if we've changed something
             if ($original->FieldValue != $value) {
                 $this->_db->setQuery("UPDATE #__rsform_submission_values SET FieldValue='" . $this->_db->escape($value) . "' WHERE SubmissionValueId='" . $original->SubmissionValueId . "' LIMIT 1");
                 $this->_db->execute();
             }
         }
     }
     $offset = JFactory::getConfig()->get('offset');
     if ($static && $staticFields) {
         // Static, update submission
         $query = $this->_db->getQuery(true);
         $query->update('#__rsform_submissions')->where($this->_db->qn('SubmissionId') . '=' . $this->_db->q($cid));
         foreach ($staticFields as $field) {
             if (!isset($static[$field])) {
                 $static[$field] = '';
             }
             if ($field == 'DateSubmitted') {
                 $static[$field] = JFactory::getDate($static[$field], $offset)->toSql();
             }
             $query->set($this->_db->qn($field) . '=' . $this->_db->q($static[$field]));
         }
         $this->_db->setQuery($query);
         $this->_db->execute();
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:directory.php

示例7: processForm

 public static function processForm($formId)
 {
     $mainframe = JFactory::getApplication();
     $formId = (int) $formId;
     $db = JFactory::getDBO();
     $db->setQuery("SELECT `FormLayoutName`, `Keepdata`, `ConfirmSubmission`, `ScriptProcess`, `ScriptProcess2`, `UserEmailScript`, `AdminEmailScript`, `ReturnUrl`, `ShowThankyou`, `Thankyou`, `ShowContinue` FROM #__rsform_forms WHERE `FormId`='" . $formId . "'");
     $form = $db->loadObject();
     $lang = RSFormProHelper::getCurrentLanguage();
     $translations = RSFormProHelper::getTranslations('forms', $formId, $lang);
     if ($translations) {
         foreach ($translations as $field => $value) {
             if (isset($form->{$field})) {
                 $form->{$field} = $value;
             }
         }
     }
     $invalid = RSFormProHelper::validateForm($formId);
     $post = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
     //Trigger Event - onBeforeFormValidation
     $mainframe->triggerEvent('rsfp_f_onBeforeFormValidation', array(array('invalid' => &$invalid, 'formId' => $formId, 'post' => &$post)));
     $userEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
     $adminEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
     $_POST['form'] = $post;
     $RSadapter = RSFormProHelper::getLegacyAdapter();
     eval($form->ScriptProcess);
     if (!empty($invalid)) {
         return $invalid;
     }
     $post = $_POST['form'];
     //Trigger Event - onBeforeFormProcess
     $mainframe->triggerEvent('rsfp_f_onBeforeFormProcess', array(array('post' => &$post)));
     if (empty($invalid)) {
         // Cache enabled ?
         jimport('joomla.plugin.helper');
         $cache_enabled = JPluginHelper::isEnabled('system', 'cache');
         if ($cache_enabled) {
             RSFormProHelper::cleanCache();
         }
         $user = JFactory::getUser();
         $confirmsubmission = $form->ConfirmSubmission ? 0 : 1;
         // Add to db (submission)
         $date = JFactory::getDate();
         $db->setQuery("INSERT INTO #__rsform_submissions SET `FormId`='" . $formId . "', `DateSubmitted`='" . $date->toSql() . "', `UserIp`='" . (isset($_SERVER['REMOTE_ADDR']) ? $db->escape($_SERVER['REMOTE_ADDR']) : '') . "', `Username`='" . $db->escape($user->get('username')) . "', `UserId`='" . (int) $user->get('id') . "', `Lang`='" . RSFormProHelper::getCurrentLanguage() . "', `confirmed` = '" . $confirmsubmission . "' ");
         $db->execute();
         $SubmissionId = $db->insertid();
         $files = JRequest::get('files');
         if (isset($files['form']['tmp_name']) && is_array($files['form']['tmp_name'])) {
             $names = array();
             foreach ($files['form']['tmp_name'] as $fieldName => $val) {
                 if ($files['form']['error'][$fieldName]) {
                     continue;
                 }
                 $names[] = $db->escape($fieldName);
             }
             $componentIds = array();
             if (!empty($names)) {
                 $db->setQuery("SELECT c.ComponentId, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId AND p.PropertyName='NAME') WHERE c.FormId='" . $formId . "' AND p.PropertyValue IN ('" . implode("','", $names) . "')");
                 $results = $db->loadObjectList();
                 foreach ($results as $result) {
                     $componentIds[$result->PropertyValue] = $result->ComponentId;
                 }
             }
             $all_data = RSFormProHelper::getComponentProperties($componentIds);
             jimport('joomla.filesystem.file');
             foreach ($files['form']['tmp_name'] as $fieldName => $val) {
                 if ($files['form']['error'][$fieldName]) {
                     continue;
                 }
                 $data = @$all_data[$componentIds[$fieldName]];
                 if (empty($data)) {
                     continue;
                 }
                 // Prefix
                 $prefix = uniqid('') . '-';
                 if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
                     $prefix = RSFormProHelper::isCode($data['PREFIX']);
                 }
                 // Path
                 $realpath = realpath($data['DESTINATION'] . DIRECTORY_SEPARATOR);
                 if (substr($realpath, -1) != DIRECTORY_SEPARATOR) {
                     $realpath .= DIRECTORY_SEPARATOR;
                 }
                 // Filename
                 $file = $realpath . $prefix . $files['form']['name'][$fieldName];
                 // Upload File
                 JFile::upload($files['form']['tmp_name'][$fieldName], $file);
                 // Add to db (submission value)
                 $db->setQuery("INSERT INTO #__rsform_submission_values SET `SubmissionId`='" . $SubmissionId . "', `FormId`='" . $formId . "', `FieldName`='" . $db->escape($fieldName) . "', `FieldValue`='" . $db->escape($file) . "'");
                 $db->execute();
                 $emails = !empty($data['EMAILATTACH']) ? explode(',', $data['EMAILATTACH']) : array();
                 // Attach to user and admin email
                 if (in_array('useremail', $emails)) {
                     $userEmail['files'][] = $file;
                 }
                 if (in_array('adminemail', $emails)) {
                     $adminEmail['files'][] = $file;
                 }
             }
         }
         // birthDay Field
//.........这里部分代码省略.........
开发者ID:alvarovladimir,项目名称:messermeister_ab_rackservers,代码行数:101,代码来源:rsform.php

示例8: processForm

 function processForm($formId)
 {
     $mainframe =& JFactory::getApplication();
     $formId = (int) $formId;
     $db = JFactory::getDBO();
     $db->setQuery("SELECT `Keepdata`, `ConfirmSubmission`, `ScriptProcess`, `ScriptProcess2`, `UserEmailScript`, `AdminEmailScript`, `ReturnUrl`, `ShowThankyou`, `Thankyou`, `ShowContinue` FROM #__rsform_forms WHERE `FormId`='" . $formId . "'");
     $form = $db->loadObject();
     $lang = RSFormProHelper::getCurrentLanguage();
     $translations = RSFormProHelper::getTranslations('forms', $formId, $lang);
     if ($translations) {
         foreach ($translations as $field => $value) {
             if (isset($form->{$field})) {
                 $form->{$field} = $value;
             }
         }
     }
     $invalid = RSFormProHelper::validateForm($formId);
     //Trigger Event - onBeforeFormValidation
     $mainframe->triggerEvent('rsfp_f_onBeforeFormValidation', array(array('invalid' => &$invalid)));
     $userEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
     $adminEmail = array('to' => '', 'cc' => '', 'bcc' => '', 'from' => '', 'replyto' => '', 'fromName' => '', 'text' => '', 'subject' => '', 'files' => array());
     $post = JRequest::getVar('form', array(), 'post', 'none', JREQUEST_ALLOWRAW);
     $_POST['form'] = $post;
     $RSadapter = RSFormProHelper::getLegacyAdapter();
     eval($form->ScriptProcess);
     if (!empty($invalid)) {
         return $invalid;
     }
     $post = $_POST['form'];
     //Trigger Event - onBeforeFormProcess
     $mainframe->triggerEvent('rsfp_f_onBeforeFormProcess');
     if (empty($invalid)) {
         // Cache enabled ?
         jimport('joomla.plugin.helper');
         $cache_enabled = JPluginHelper::isEnabled('system', 'cache');
         if ($cache_enabled) {
             RSFormProHelper::cleanCache();
         }
         $user = JFactory::getUser();
         $confirmsubmission = $form->ConfirmSubmission ? 0 : 1;
         // Add to db (submission)
         $db->setQuery("INSERT INTO #__rsform_submissions SET `FormId`='" . $formId . "', `DateSubmitted`=NOW(), `UserIp`='" . (isset($_SERVER['REMOTE_ADDR']) ? $db->getEscaped($_SERVER['REMOTE_ADDR']) : '') . "', `Username`='" . $db->getEscaped($user->get('username')) . "', `UserId`='" . (int) $user->get('id') . "', `Lang`='" . RSFormProHelper::getCurrentLanguage() . "', `confirmed` = '" . $confirmsubmission . "' ");
         $db->query();
         $SubmissionId = $db->insertid();
         $files = JRequest::get('files');
         if (isset($files['form']['tmp_name']) && is_array($files['form']['tmp_name'])) {
             $names = array();
             foreach ($files['form']['tmp_name'] as $fieldName => $val) {
                 if ($files['form']['error'][$fieldName]) {
                     continue;
                 }
                 $names[] = $db->getEscaped($fieldName);
             }
             $componentIds = array();
             if (!empty($names)) {
                 $db->setQuery("SELECT c.ComponentId, p.PropertyValue FROM #__rsform_components c LEFT JOIN #__rsform_properties p ON (c.ComponentId=p.ComponentId AND p.PropertyName='NAME') WHERE c.FormId='" . $formId . "' AND p.PropertyValue IN ('" . implode("','", $names) . "')");
                 $results = $db->loadObjectList();
                 foreach ($results as $result) {
                     $componentIds[$result->PropertyValue] = $result->ComponentId;
                 }
             }
             $all_data = RSFormProHelper::getComponentProperties($componentIds);
             jimport('joomla.filesystem.file');
             foreach ($files['form']['tmp_name'] as $fieldName => $val) {
                 if ($files['form']['error'][$fieldName]) {
                     continue;
                 }
                 $data = @$all_data[$componentIds[$fieldName]];
                 if (empty($data)) {
                     continue;
                 }
                 // Prefix
                 $prefix = uniqid('') . '-';
                 if (isset($data['PREFIX']) && strlen(trim($data['PREFIX'])) > 0) {
                     $prefix = RSFormProHelper::isCode($data['PREFIX']);
                 }
                 // Path
                 $realpath = realpath($data['DESTINATION'] . DS);
                 if (substr($realpath, -1) != DS) {
                     $realpath .= DS;
                 }
                 // Filename
                 $file = $realpath . $prefix . $files['form']['name'][$fieldName];
                 // Upload File
                 JFile::upload($files['form']['tmp_name'][$fieldName], $file);
                 // Add to db (submission value)
                 $db->setQuery("INSERT INTO #__rsform_submission_values SET `SubmissionId`='" . $SubmissionId . "', `FormId`='" . $formId . "', `FieldName`='" . $db->getEscaped($fieldName) . "', `FieldValue`='" . $db->getEscaped($file) . "'");
                 $db->query();
                 $emails = !empty($data['EMAILATTACH']) ? explode(',', $data['EMAILATTACH']) : array();
                 // Attach to user and admin email
                 if (in_array('useremail', $emails)) {
                     $userEmail['files'][] = $file;
                 }
                 if (in_array('adminemail', $emails)) {
                     $adminEmail['files'][] = $file;
                 }
             }
         }
         //Trigger Event - onBeforeStoreSubmissions
         $mainframe->triggerEvent('rsfp_f_onBeforeStoreSubmissions', array(array('formId' => $formId, 'post' => &$post, 'SubmissionId' => $SubmissionId)));
//.........这里部分代码省略.........
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:101,代码来源:rsform.php


注:本文中的RSFormProHelper::validateForm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。