Example #1
0
 function display($tmp = null)
 {
     // Load assets
     JSNUniformHelper::addAssets();
     $lang = JFactory::getLanguage();
     $input = JFactory::getApplication()->input;
     $extensionId = $input->getInt('extension_id', 0);
     $model = $this->getModel();
     $extension = $model->getExtensionInfo($extensionId);
     if (!count($extension)) {
         $html = '<br/> <div class="alert alert-danger">' . JText::_('JSN_UNIFORM_EXTENSION_NOT_FOUND') . '</div>';
         echo $html;
         return;
     }
     $this->extension_name = (string) $extension->element;
     if (JPluginHelper::isEnabled('uniform', (string) $this->extension_name) !== true) {
         $html = '<br/> <div class="alert alert-danger">' . JText::sprintf('JSN_UNIFORM_PLUGIN_IS_NOT_EXISTED_OR_ENABLED', strtoupper(str_replace('_', ' ', (string) $this->extension_name))) . '</div>';
         echo $html;
         return;
     }
     parent::display($tmp);
     // Load assets
     JSNUniformHelper::addAssets();
     $this->addAssets();
 }
Example #2
0
 /**
  * Method for display page.
  *
  * @param   boolean  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a JError object.
  */
 public function display($tpl = null)
 {
     // Load assets
     JSNUniformHelper::addAssets();
     parent::display($tpl);
     echo JSNHtmlAsset::loadScript('uniform/emailuser', array(), true);
 }
Example #3
0
 /**
  * Launch adapter
  *
  * @return  boolean
  */
 function launchAdapter()
 {
     // Get user input
     $app = JFactory::getApplication();
     $type = $app->input->getCmd('type');
     $formId = $app->input->getInt('form_id');
     // Store user state
     $app->setUserState('com_uniform.add.form_id', $formId);
     switch ($type) {
         case 'module':
             // Get module info
             $moduleInfo = JSNUniformHelper::getModuleInfo();
             // Generate redirect link
             $link = 'index.php?option=com_modules&task=module.add&eid=' . $moduleInfo->extension_id;
             $this->setRedirect($link);
             break;
         case 'menu':
             // Get component info
             $componentInfo = JSNUniformHelper::getComponentInfo();
             // Generate data for creating new menu item
             $data = array('type' => 'component', 'title' => '', 'alias' => '', 'note' => '', 'link' => 'index.php?option=com_uniform&view=form', 'published' => '1', 'access' => '1', 'menutype' => $this->input->getCmd('menutype'), 'parent_id' => '1', 'browserNav' => '0', 'home' => '0', 'language' => '*', 'template_style_id' => '0', 'id' => '0', 'component_id' => $componentInfo->extension_id);
             // Fake user state for add/edit menu item page
             $app->setUserState('com_menus.edit.item.data', $data);
             $app->setUserState('com_menus.edit.item.type', 'component');
             $app->setUserState('com_menus.edit.item.link', 'index.php?option=com_uniform&view=form');
             // Generate redirect link
             $link = 'index.php?option=com_menus&view=item&layout=edit';
             $this->setRedirect($link);
             break;
     }
     return true;
 }
Example #4
0
 /**
  * Method for display page.
  *
  * @param   boolean  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a JError object.
  */
 public function display($tpl = null)
 {
     // Load assets
     JSNUniformHelper::addAssets();
     // Display the template
     parent::display($tpl);
 }
 /**
  * Method to get the field input markup.
  *
  * @return	string	The field input markup.
  * 
  * @since	1.6
  */
 protected function getInput()
 {
     $items = null;
     if (!empty($this->value) && is_string($this->value)) {
         $items = json_decode($this->value);
     }
     return JSNUniformHelper::getListEmailNotification($items);
 }
Example #6
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 protected function getInput()
 {
     $columnTableFormData = JSNUniformHelper::getFormData();
     $arrayTranslated = array();
     $html = "<div class=\"jsn-master\"><div id=\"page-loading\" class=\"jsn-bgloading\"><i class=\"jsn-icon32 jsn-icon-loading\"></i></div><div class=\"jsn-bootstrap menu-items\"><input type='hidden' id='uniform_field' name='" . $this->name . "' value='" . $this->value . "' /><ul class=\"jsn-items-list ui-sortable hide\" id=\"form_field\">";
     $html .= "</ul></div></div>";
     JSNHtmlAsset::loadScript('uniform/menusubmissions', array('value' => $this->value, 'name' => 'uniform_listField', 'columnTableFormData' => $columnTableFormData, 'language' => JSNUtilsLanguage::getTranslated($arrayTranslated)));
     return $html;
 }
Example #7
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 protected function getInput()
 {
     $name = $this->name;
     $app = JFactory::getApplication();
     if (!$this->value) {
         $this->value = $app->getUserState('com_uniform.add.form_id');
     }
     return JSNUniformHelper::getSelectForm($name, $this->id, "menuform", $this->value, true);
 }
Example #8
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a JError object.
  *
  * @see     fetch()
  * @since   11.1
  */
 public function display($tpl = null)
 {
     // Initialize variables
     $this->_document = JFactory::getDocument();
     $this->_form = $this->get('Form');
     $this->_item = $this->get('Item');
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     parent::display($tpl);
     // Load assets
     JSNUniformHelper::addAssets();
     $this->_addAssets();
 }
Example #9
0
 /**
  * Constructor
  *
  * @param   array  $config  An array of configuration options.
  */
 public function __construct($config = array())
 {
     parent::__construct($config);
     // Load language manually
     $lang = JFactory::getLanguage();
     $lang->load('jsn_installer', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/joomlashine/installer');
     // Get application object
     $this->app = JFactory::getApplication();
     // Get input object
     $this->input = $this->app->input;
     // Get Joomla config
     $this->config = JFactory::getConfig();
     require_once JPATH_COMPONENT_ADMINISTRATOR . "/helpers/uniform.php";
     JSNUniformHelper::convertTableSubmissions('update');
     JSNUniformHelper::convertTableSubmissionData('update');
 }
Example #10
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a JError object.
  *
  * @see     fetch()
  * @since   11.1
  */
 function display($tpl = null)
 {
     // Get config parameters
     $config = JSNConfigHelper::get();
     // Set the toolbar
     JToolBarHelper::title(JText::_('JSN_UNIFORM_UPGRADE_PRODUCT'));
     // Load assets
     JSNUniformHelper::addAssets();
     // Get messages
     $msgs = '';
     if (!$config->get('disable_all_messages')) {
         $msgs = JSNUtilsMessage::getList('CONFIGURATION');
         $msgs = count($msgs) ? JSNUtilsMessage::showMessages($msgs) : '';
     }
     // Assign variables for rendering
     $this->assignRef('msgs', $msgs);
     // Display the template
     parent::display($tpl);
 }
 /**
  * Get the button.
  *
  * @return  string
  */
 public function fetchButton()
 {
     $subMenuItemLists = JSNUniformHelper::getForms(5);
     // Build options
     //	$options[] = array(
     //	    'title'    => JText::_('JSN_UNIFORM_SUBMENU_LAUNCHPAD'),
     //	    'link'     => 'index.php?option=com_uniform',
     //	    'class'    => 'parent primary',
     //	    'icon'     => 'icon-off'
     //	);
     $options[] = array('title' => JText::_('JSN_UNIFORM_SUBMENU_FORMS'), 'link' => 'index.php?option=com_uniform&view=forms', 'class' => 'parent primary', 'sub_menu_link' => 'index.php?option=com_uniform&view=form&task=form.edit&form_id={$form_id}', 'sub_menu_field_title' => 'form_title', 'sub_menu_link_add_title' => 'Create new forms', 'sub_menu_link_add' => 'index.php?option=com_uniform&view=form&layout=edit', 'data_sub_menu' => $subMenuItemLists, 'icon' => 'jsn-icon-finder');
     $options[] = array('title' => JText::_('JSN_UNIFORM_SUBMENU_SUBMISSION'), 'link' => 'index.php?option=com_uniform&view=submissions', 'class' => 'parent primary', 'icon' => 'jsn-icon-file');
     $options[] = array('class' => 'separator');
     $options[] = array('title' => JText::_('JSN_UNIFORM_SUBMENU_CONFIGURATION'), 'link' => 'index.php?option=com_uniform&view=configuration');
     $options[] = array('title' => JText::_('JSN_UNIFORM_SUBMENU_ABOUT'), 'link' => 'index.php?option=com_uniform&view=about');
     // Generate HTML code for sub-menu
     $html = JSNHtmlGenerate::menuToolbar($options);
     return $html;
 }
Example #12
0
 /**
  * Display method
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return void
  */
 public function display($tpl = null)
 {
     // Set toolbar title
     JToolBarHelper::title(JText::_('JSN_UNIFORM_HELP_HELP_AND_SUPPORT'));
     // Get config
     $config = JSNConfigHelper::get();
     // Get messages
     $msgs = '';
     if (!$config->get('disable_all_messages')) {
         $msgs = JSNUtilsMessage::getList('HELP');
         $msgs = count($msgs) ? JSNUtilsMessage::showMessages($msgs) : '';
     }
     // Load assets
     JSNUniformHelper::addAssets();
     // Assign variables for rendering
     $this->assignRef('msgs', $msgs);
     // Display the template
     parent::display($tpl);
 }
Example #13
0
    /**
     *  view select form
     * 
     * @return html code
     */
    public function viewSelectForm()
    {
        $user = JFactory::getUser();
        $userId = $user->get('id');
        $isCreate = (bool) $user->authorise('core.create');
        $isEdit = (bool) $user->authorise('core.edit');
        if (!$userId || !$isCreate && !$isEdit) {
            throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'));
        }
        $uri = JUri::root(true);
        $document = JFactory::getDocument();
        $document->addScript($uri . '/media/system/js/mootools-core.js');
        $document->addScript($uri . '/media/system/js/core.js');
        $document->addScript($uri . '/media/system/js/mootools-more.js');
        JHtml::_('jquery.framework');
        $jsCode = '(function($){
				$(document).ready(function () {
					var form = $("select.jform_request_form_id");
					form.change(function () {
					if (form.val() == 0) {
                        $(this).css("background", "#CC0000").css("color", "#fff")
                        $("#select-forms").attr("disabled", "disabled");
                    } else {
                        $("#select-forms").removeAttr("disabled");
                        form.css("background", "#FFFFDD").css("color", "#000")
                    }						
					}).trigger("change");
					
					$("#select-forms").click(function () {
	                    if (window.parent)
	                    {
	                        window.parent.jsnSelectForm($("select.jform_request_form_id").val());
	                    }
	                });
				});
			})(jQuery)';
        $document->addScriptDeclaration($jsCode);
        echo JSNUniformHelper::getSelectForm('jform[params][form_id]', 'jform_params_form_id', "contentfrontend");
    }
Example #14
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a JError object.
  */
 function display($tpl = null)
 {
     // Get config parameters
     $config = JSNConfigHelper::get();
     // Initialize toolbar
     JSNUniformHelper::initToolbar('JSN_UNIFORM_ABOUT', 'uniform-about', false);
     // Get messages
     $msgs = '';
     if (!$config->get('disable_all_messages')) {
         $msgs = JSNUtilsMessage::getList('ABOUT');
         $msgs = count($msgs) ? JSNUtilsMessage::showMessages($msgs) : '';
     }
     // Load assets
     JSNUniformHelper::addAssets();
     // Assign variables for rendering
     $this->assignRef('msgs', $msgs);
     // Load the submenu.
     $input = JFactory::getApplication()->input;
     JSNUniformHelper::addSubmenu($input->get('view', 'about'));
     // Display the template
     parent::display($tpl);
 }
Example #15
0
 /**
  *     get html form
  *
  * @return string
  */
 function getHtmlForm()
 {
     $formId = JRequest::getVar('form_id', '');
     if ($formId) {
         $formName = md5(date("Y-m-d H:i:s")) . rand(0, 1000);
         echo JSNUniformHelper::generateHTMLPages($formId, $formName, "ajax");
         exit;
     }
 }
Example #16
0
foreach ($this->_formPages as $formPages) {
    $pageContent = json_decode($formPages->page_content);
    $submissionDetail = "";
    $submissionEdit = "";
    foreach ($pageContent as $fields) {
        $key = "sd_" . $fields->id;
        if (isset($fields->type) && $fields->type != 'static-content' && $fields->type != 'google-maps') {
            if (isset($submission->{$key})) {
                $submissionDetail .= '<dt>' . $fields->label . ':</dt><dd id="' . $key . '">';
                $submissionEdit .= '<div class="control-group ">
												<label class="control-label">' . $fields->label . ':</label>
												<div class="controls">';
                $contentField = "";
                $contentFieldEdit = "";
                $contentFieldDetail = "";
                $contentField = JSNUniformHelper::getDataField($fields->type, $submission, $key, $this->_item->form_id, false);
                $contentFieldEdit = $contentField;
                if ($fields->type == "email") {
                    $contentFieldDetail = !empty($contentField) ? '<a href="mailto:' . htmlentities($contentField, ENT_QUOTES, "UTF-8") . '">' . htmlentities($contentField, ENT_QUOTES, "UTF-8") . '</a>' : "N/A";
                } else {
                    $contentFieldDetail = $contentField;
                }
                $submissionDetail .= htmlentities($contentFieldDetail, ENT_QUOTES, "UTF-8") ? str_replace("\n", "<br/>", trim(htmlentities($contentFieldDetail, ENT_QUOTES, "UTF-8"))) : "N/A";
                if (isset($fields->type) && ($fields->type == "checkboxes" || $fields->type == "list" || $fields->type == "paragraph-text")) {
                    if ($fields->type == "checkboxes" || $fields->type == "list") {
                        $contentFieldEdit = str_replace("<br/>", "\n", $contentFieldEdit);
                        $contentFieldEdit = str_replace("\n\n", "\n", $contentFieldEdit);
                        $contentFieldEdit = htmlentities($contentFieldEdit, ENT_QUOTES | ENT_IGNORE, "UTF-8");
                    }
                    $submissionEdit .= "<textarea name=\"submission[{$key}]\" class=\"jsn-input-xxlarge-fluid\" dataValue='" . $fields->id . "' typeValue='" . $fields->type . "' rows=\"5\" >{$contentFieldEdit}</textarea>";
                } else {
Example #17
0
 /**
  * Add the libraries css and javascript
  *
  * @return void
  *
  * @since        1.6
  */
 protected function addAssets()
 {
     $uri = JUri::getInstance();
     $document = JFactory::getDocument();
     /** load Css  */
     $loadBootstrap = JSNUniformHelper::getDataConfig('load_bootstrap_css');
     $loadBootstrap = isset($loadBootstrap->value) ? $loadBootstrap->value : "0";
     $stylesheets = array();
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/jsnframework/assets/3rd-party/jquery-ui/css/ui-bootstrap/jquery-ui-1.9.0.custom.css');
     if (preg_match('/msie/i', $_SERVER['HTTP_USER_AGENT'])) {
         $document->addStyleSheet(JURI::root(true) . '/plugins/system/jsnframework/assets/3rd-party/jquery-ui/css/ui-bootstrap/jquery.ui.1.9.0.ie.css');
     }
     if ($loadBootstrap == 1) {
         $document->addStyleSheet(JSN_UNIFORM_ASSETS_URI . '/3rd-party/bootstrap/css/bootstrap.min.css');
     }
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/jsnframework/assets/joomlashine/css/jsn-gui.css');
     //$document->addStyleSheet(JURI::root(true) . '/plugins/system/jsnframework/assets/3rd-party/font-awesome/css/font-awesome.css');
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/jsnframework/assets/3rd-party/jquery-tipsy/tipsy.css');
     $document->addStyleSheet(JSN_UNIFORM_ASSETS_URI . '/css/form.css');
     /** end  */
     /** Load Js */
     $document->addScriptDeclaration('var nextAndPreviousForm =' . json_encode($this->nextAndPreviousForm));
     $getHeadData = JFactory::getDocument()->getHeadData();
     $checkLoadScript = true;
     $scripts = array();
     foreach ($getHeadData['scripts'] as $script => $option) {
         $scripts[$script] = $option;
         if ($script == JSN_UNIFORM_ASSETS_URI . '/js/form.js' || $script == JSN_UNIFORM_ASSETS_URI . '/js/submission.js') {
             if ($uri->getScheme() == 'https') {
                 $scripts['https://maps.google.com/maps/api/js?sensor=false&libraries=places'] = $option;
             } else {
                 $scripts['http://maps.google.com/maps/api/js?sensor=false&libraries=places'] = $option;
             }
             $scripts[JSN_UNIFORM_ASSETS_URI . '/js/libs/googlemaps/jquery.ui.map.js'] = $option;
             $scripts[JSN_UNIFORM_ASSETS_URI . '/js/libs/googlemaps/jquery.ui.map.services.js'] = $option;
             $scripts[JSN_UNIFORM_ASSETS_URI . '/js/libs/googlemaps/jquery.ui.map.extensions.js'] = $option;
             $scripts[JSN_UNIFORM_ASSETS_URI . '/js/submission.js'] = $option;
             $checkLoadScript = false;
         }
     }
     if ($checkLoadScript) {
         if ($uri->getScheme() == 'https') {
             $document->addScript('https://maps.google.com/maps/api/js?sensor=false&libraries=places');
         } else {
             $document->addScript('http://maps.google.com/maps/api/js?sensor=false&libraries=places');
         }
         $document->addScript(JURI::root(true) . '/media/jui/js/jquery.min.js');
         $document->addScript(JSN_UNIFORM_ASSETS_URI . '/js/libs/jquery-ui-1.10.3.custom.min.js');
         $document->addScript(JSN_UNIFORM_ASSETS_URI . '/js/libs/json-2.3.min.js');
         $document->addScript(JSN_UNIFORM_ASSETS_URI . '/js/libs/googlemaps/jquery.ui.map.js');
         $document->addScript(JSN_UNIFORM_ASSETS_URI . '/js/libs/googlemaps/jquery.ui.map.services.js');
         $document->addScript(JSN_UNIFORM_ASSETS_URI . '/js/libs/googlemaps/jquery.ui.map.extensions.js');
         $document->addScript(JURI::root(true) . '/plugins/system/jsnframework/assets/3rd-party/jquery-tipsy/jquery.tipsy.js');
         $document->addScript(JSN_UNIFORM_ASSETS_URI . '/js/submission.js');
     } else {
         if (!empty($scripts)) {
             $getHeadData['scripts'] = $scripts;
             JFactory::getDocument()->setHeadData($getHeadData);
         }
     }
 }
Example #18
0
 /**
  * Save data
  *
  * @param   Array   $dataForms                Data form
  * @param   Array   &$return                  Return
  * @param   Array   $post                     Post form
  * @param   String  $submissionsData          Submission Data
  * @param   String  $fieldId                  Field Id
  * @param   String  $dataContentEmail         Data content Email
  * @param   Strig   $nameFileByIndentifier    Get name Field by Indentifier
  * @param   String  $requiredField            required field
  * @param   String  $fileAttach               Email File Attach
  *
  * @return boolean
  */
 private function _save($dataForms, &$return, $post, $submissionsData, $dataContentEmail, $nameFileByIndentifier, $requiredField, $fileAttach, $recepientEmail)
 {
     $user = JFactory::getUser();
     $ip = getenv('REMOTE_ADDR');
     $country = $this->countryCityFromIP($ip);
     $browser = new Browser();
     $checkSaveSubmission = true;
     $formSettings = !empty($dataForms->form_settings) ? json_decode($dataForms->form_settings) : "";
     $plgName = JSNUniformHelper::getPluginUniform();
     if (isset($plgName) && !empty($plgName)) {
         if (is_array($plgName)) {
             foreach ($plgName as $k => $v) {
                 $v = (array) $v;
                 $name = form_ . '' . $v['value'];
                 $data[$v['value']] = $formSettings->{$name};
                 $data['post'] = $post;
                 $data['sub'] = $submissionsData;
                 if ($v['value'] == 'mailchimp') {
                     if (isset($post['mailchimp_subcriber']) && $post['mailchimp_subcriber'] == 'on') {
                         JPluginHelper::importPlugin('uniform', $v['value']);
                         $dispatcher = JDispatcher::getInstance();
                         $dispatcher->trigger('saveFrontEnd', array($data));
                     }
                 }
             }
         }
     }
     if (!empty($formSettings->action_save_submissions) && $formSettings->action_save_submissions == "No") {
         $checkSaveSubmission = false;
     }
     if ($checkSaveSubmission) {
         $dateTime = JHtml::_('date', 'now', JText::_('Y-m-d H:i:s'));
         $table = JTable::getInstance('JsnSubmission', 'JSNUniformTable');
         $table->bind(array('form_id' => (int) $post['form_id'], 'user_id' => $user->id, 'submission_ip' => $ip, 'submission_country' => $country['country'], 'submission_country_code' => $country['country_code'], 'submission_browser' => $browser->getBrowser(), 'submission_browser_version' => $browser->getVersion(), 'submission_browser_agent' => $browser->getUserAgent(), 'submission_os' => $browser->getPlatform(), 'submission_created_by' => $user->id, 'submission_created_at' => $dateTime, 'submission_state' => 1));
         if (!$table->store()) {
             $return->error = $table->getError();
             return false;
         }
     }
     $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_templates')->where("form_id = " . (int) $dataForms->form_id));
     $dataTemplates = $this->_db->loadObjectList();
     $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_emails')->where("form_id = " . (int) $dataForms->form_id));
     $dataEmails = $this->_db->loadObjectList();
     if (count($recepientEmail)) {
         $recepientEmail = json_decode($recepientEmail);
         foreach ($recepientEmail as $recepient) {
             $recepient = explode('|', $recepient);
             $emailName = trim($recepient[0]);
             $email = trim(end($recepient));
             $dataRecepient = (object) array('email_id' => '', 'form_id' => '', 'user_id' => '0', 'email_name' => $emailName, 'email_address' => $email, 'email_state' => '1');
             $dataEmails = array_merge($dataEmails, array($dataRecepient));
         }
     }
     $formSubmitter = isset($dataForms->form_submitter) ? json_decode($dataForms->form_submitter) : '';
     $checkEmailSubmitter = true;
     $defaultSubject = isset($dataForms->form_title) ? $dataForms->form_title : '';
     if ($dataTemplates) {
         foreach ($dataTemplates as $emailTemplate) {
             if (!empty($emailTemplate->template_message)) {
                 $emailTemplate->template_message = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_message);
             } else {
                 $htmlMessage = array();
                 if ($dataContentEmail) {
                     $htmlMessage = $this->_emailTemplateDefault($dataContentEmail, $nameFileByIndentifier, $requiredField);
                 }
                 $emailTemplate->template_message = $htmlMessage;
             }
             $emailTemplate->template_subject = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_subject);
             $emailTemplate->template_subject = !empty($emailTemplate->template_subject) ? $emailTemplate->template_subject : $defaultSubject;
             $emailTemplate->template_from = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_from);
             $emailTemplate->template_reply_to = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_reply_to);
             $emailTemplate->template_subject = strip_tags($emailTemplate->template_subject);
             $emailTemplate->template_from = strip_tags($emailTemplate->template_from);
             $emailTemplate->template_reply_to = strip_tags($emailTemplate->template_reply_to);
             if ($emailTemplate->template_notify_to == 0 && count($formSubmitter)) {
                 $checkEmailSubmitter = false;
                 $listEmailSubmitter = array();
                 foreach ($formSubmitter as $item) {
                     if (!empty($item)) {
                         $emailSubmitter = new stdClass();
                         $emailSubmitter->email_address = isset($dataContentEmail[$item]) ? $dataContentEmail[$item] : "";
                         if (!empty($emailSubmitter->email_address)) {
                             $listEmailSubmitter[] = $emailSubmitter;
                         }
                     }
                 }
                 $sent = $this->_sendEmailList($emailTemplate, $listEmailSubmitter, $fileAttach);
                 // Set the success message if it was a success
                 if (!JError::isError($sent)) {
                     $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
                 }
             }
             if ($emailTemplate->template_notify_to == 1) {
                 $sent = $this->_sendEmailList($emailTemplate, $dataEmails, $fileAttach);
                 // Set the success message if it was a success
                 if (!JError::isError($sent)) {
                     $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
                 }
             }
         }
     }
     if ($checkEmailSubmitter && count($formSubmitter)) {
         $emailTemplate = new stdClass();
         $htmlMessage = array();
         if ($dataContentEmail) {
             $htmlMessage = $this->_emailTemplateDefault($dataContentEmail, $nameFileByIndentifier, $requiredField);
         }
         $emailTemplate->template_message = $htmlMessage;
         $listEmailSubmitter = array();
         foreach ($formSubmitter as $item) {
             if (!empty($item)) {
                 $emailSubmitter = new stdClass();
                 $emailSubmitter->email_address = isset($dataContentEmail[$item]) ? $dataContentEmail[$item] : "";
                 if (!empty($emailSubmitter->email_address)) {
                     $listEmailSubmitter[] = $emailSubmitter;
                 }
             }
         }
         $sent = $this->_sendEmailList($emailTemplate, $listEmailSubmitter);
         // Set the success message if it was a success
         if (!JError::isError($sent)) {
             $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
         }
     }
     if ($checkSaveSubmission) {
         foreach ($submissionsData as $submission) {
             if (!empty($submission)) {
                 $submission['submission_id'] = $table->submission_id;
                 if ($post['use_payment_gateway'] == 1) {
                     $dispatcher = JEventDispatcher::getInstance();
                     JPluginHelper::importPlugin('uniform', (string) $dataForms->form_payment_type);
                     if ($submission['field_type'] == 'choices' || $submission['field_type'] == 'list' || $submission['field_type'] == 'dropdown' || $submission['field_type'] == 'checkboxes' || $submission['field_type'] == 'currency' || $submission['field_type'] == 'number') {
                         $fieldValue = $submission['submission_data_value'];
                         if ($submission['field_type'] == 'list' || $submission['field_type'] == 'checkboxes') {
                             $fieldValue = json_decode($fieldValue);
                             $submissionValue = array();
                             foreach ($fieldValue as $itemValue) {
                                 $tmpMoney = explode('|', $itemValue);
                                 $moneyValue = trim($tmpMoney[1]);
                                 $moneyValue = $dispatcher->trigger('displayCurrency', $moneyValue);
                                 $qty = trim(end($tmpMoney));
                                 $tmpMoney = trim($tmpMoney[0]) . ' (' . strip_tags($moneyValue[0]) . ' x ' . $qty . ')';
                                 $submissionValue[] = json_encode($tmpMoney);
                             }
                             if (!empty($submissionValue)) {
                                 $submission['submission_data_value'] = '[' . implode(',', $submissionValue) . ']';
                             }
                         } else {
                             $tmpMoney = explode('|', $fieldValue);
                             $moneyValue = trim($tmpMoney[1]);
                             if ($moneyValue != '') {
                                 $moneyValue = $dispatcher->trigger('displayCurrency', $moneyValue);
                                 $qty = trim(end($tmpMoney));
                                 $submission['submission_data_value'] = trim($tmpMoney[0]) . ' (' . strip_tags($moneyValue[0]) . ' x ' . $qty . ')';
                             } else {
                                 $submission['submission_data_value'] = $fieldValue;
                             }
                         }
                         if ($submission['field_type'] == 'currency') {
                             if (!empty($fieldValue)) {
                                 $fieldValue = str_replace(',', '.', $fieldValue);
                                 $currecyValue = $dispatcher->trigger('displayCurrency', $fieldValue);
                                 $currecyValue = strip_tags($currecyValue[0]);
                                 $submission['submission_data_value'] = $currecyValue;
                             }
                         }
                     }
                 }
                 $tableSubmission = JTable::getInstance('JsnSubmissiondata', 'JSNUniformTable');
                 $tableSubmission->bind($submission);
                 if (!$tableSubmission->store()) {
                     $return->error = $tableSubmission->getError();
                     return false;
                 }
             }
         }
         $this->_db->setQuery($this->_db->getQuery(true)->select('count(submission_id)')->from("#__jsn_uniform_submissions")->where("form_id=" . (int) $post['form_id']));
         $countSubmission = $this->_db->loadResult();
         $edition = defined('JSN_UNIFORM_EDITION') ? strtolower(JSN_UNIFORM_EDITION) : "free";
         if ($countSubmission == 250 && $edition == "free") {
             $templateEmail = new stdClass();
             $templateEmail->template_subject = $defaultSubject;
             $templateEmail->template_message = "<p>Hello there,</p>\n\t    <p>This is a quick message to let you know you're getting lots of submissions of your form which will soon exceed limit. Please upgrade to PRO edition to accept unlimited number of submissions. <a href=\"http://www.joomlashine.com/joomla-extensions/jsn-uniform-download.html\" target=\"_blank\">Upgrade now</a>.</p>\n\t    <p>Thank you and all the best,</p>\n\t    <p>The JoomlaShine Team</p>";
             $app = JFactory::getApplication();
             $mailfrom = $app->getCfg('mailfrom');
             $emailMaster = new stdClass();
             $emailMaster->email_address = $mailfrom;
             $this->_sendEmailList($templateEmail, array($emailMaster));
         }
         $table = JTable::getInstance('JsnForm', 'JSNUniformTable');
         $table->bind(array('form_id' => (int) $post['form_id'], 'form_last_submitted' => date('Y-m-d H:i:s'), 'form_submission_cout' => $countSubmission));
         if (!$table->store()) {
             $return->error = $table->getError();
             return false;
         }
     }
     if (!empty($_SESSION['securimage_code_value'][$_POST['form_name']])) {
         unset($_SESSION['securimage_code_value'][$_POST['form_name']]);
         unset($_SESSION['securimage_code_disp'][$_POST['form_name']]);
         unset($_SESSION['securimage_code_ctime'][$_POST['form_name']]);
     }
     return true;
 }
Example #19
0
 /**
  * Setup toolbar.
  *
  * @return void
  */
 protected function initToolbar()
 {
     JToolBarHelper::apply('form.apply');
     JToolBarHelper::save('form.save');
     // Create a toolbar button that drop-down a sub-menu when clicked
     JSNMenuHelper::addEntry('toolbar-save', 'JSN_UNIFORM_SAVE_AND_SHOW', '', false, 'jsn-icon16 jsn-icon-file', 'toolbar');
     // Declare 1st-level menu items
     JSNMenuHelper::addEntry('component', 'JSN_UNIFORM_FORM_VIA_MENU_ITEM_COMPONENT', '', false, '', 'toolbar-save');
     JSNMenuHelper::addEntry('module', 'JSN_UNIFORM_FORM_IN_MODULE_POSITION_MODULE', 'index.php?option=com_uniform&task=launchAdapter&type=module', false, '', 'toolbar-save', 'action-save-show');
     JSNMenuHelper::addEntry('article-content-plugin', 'JSN_UNIFORM_FORM_INSIDE_ARTICLE_CONTENT_PLUGIN', '', false, '', 'toolbar-save');
     if (count($optionMenus = JSNUniformHelper::getOptionMenus())) {
         foreach ($optionMenus as $option) {
             JSNMenuHelper::addEntry(preg_replace('/[^a-z0-9\\-_]/', '-', $option->text), $option->text, 'index.php?option=com_uniform&task=launchAdapter&type=menu&menutype=' . $option->value, false, '', 'toolbar-save.component', 'action-save-show');
         }
     }
     JToolBarHelper::cancel('form.cancel', 'JSN_UNIFORM_CLOSE');
     JSNUniformHelper::initToolbar('JSN_UNIFORM_FORM_PAGETITLE', 'uniform-forms', false);
 }
Example #20
0
 /**
  * get count field
  *
  * @return  void
  */
 public static function getcountfield()
 {
     $post = $_POST;
     $fieldId = isset($post['field_id']) ? $post['field_id'] : 0;
     $formId = isset($post['form_id']) ? $post['form_id'] : 0;
     if ($formId && $fieldId) {
         echo json_encode(JSNUniformHelper::getDataSumbissionByField($fieldId, $formId));
     }
     jexit();
 }
Example #21
0
 /**
  * Do any preparation needed before doing real data restore.
  *
  * @param   string   &$backup       Path to folder containing extracted backup files.
  * @param   boolean  $checkEdition  Check for matching edition before restore?
  *
  * @return  void
  */
 protected function beforeRestore(&$backup, $checkEdition = true)
 {
     // Initialize variables
     $com = preg_replace('/^com_/i', '', JFactory::getApplication()->input->getCmd('option'));
     $info = JSNUtilsXml::loadManifestCache();
     $jVer = new JVersion();
     // Extract backup file
     if (!JArchive::extract($backup, substr($backup, 0, -4))) {
         throw new Exception(JText::_('JSN_EXTFW_DATA_EXTRACT_UPLOAD_FILE_FAIL'));
     }
     $backup = substr($backup, 0, -4);
     // Auto-detect backup XML file
     $files = glob("{$backup}/*.xml");
     foreach ($files as $file) {
         $this->data = JSNUtilsXml::load($file);
         // Check if this XML file contain backup data for our product
         if (strcasecmp($this->data->getName(), 'backup') == 0 and isset($this->data['extension-name']) and isset($this->data['extension-version']) and isset($this->data['joomla-version'])) {
             // Store backup XML file name
             $this->xml = basename($file);
             // Simply break the loop if we found backup file
             break;
         }
         unset($this->data);
     }
     if (isset($this->data)) {
         // Check if Joomla series match
         if (!$jVer->isCompatible((string) $this->data['joomla-version'])) {
             throw new Exception(JText::_('JSN_EXTFW_DATA_JOOMLA_VERSION_NOT_MATCH'));
         }
         // Check if extension match
         if ((string) $this->data['extension-name'] != 'JSN ' . preg_replace('/JSN\\s*/i', '', JText::_($info->name))) {
             throw new Exception(JText::_('JSN_EXTFW_DATA_INVALID_PRODUCT'));
         } elseif (isset($this->data['extension-edition']) and $checkEdition and (!($const = JSNUtilsText::getConstant('EDITION')) or (string) $this->data['extension-edition'] != $const)) {
             throw new Exception(JText::_('JSN_EXTFW_DATA_INVALID_PRODUCT_EDITION'));
         } elseif (!version_compare($info->version, (string) $this->data['extension-version'], '=') and !$checkEdition) {
             // Get update link for out-of-date product
             $ulink = $info->authorUrl;
             if (isset($this->data['update-url'])) {
                 $ulink = (string) $this->data['update-url'];
             } elseif ($const = JSNUtilsText::getConstant('UPDATE_LINK')) {
                 $ulink = $const;
             }
             throw new Exception(JText::_('JSN_EXTFW_DATA_PRODUCT_VERSION_OUTDATE') . '&nbsp;<a href="' . $ulink . '" class="jsn-link-action">' . JText::_('JSN_EXTFW_GENERAL_UPDATE_NOW') . '</a>');
         } elseif (!version_compare($info->version, (string) $this->data['extension-version'], 'ge')) {
             // Get update link for out-of-date product
             $ulink = $info->authorUrl;
             if (isset($this->data['update-url'])) {
                 $ulink = (string) $this->data['update-url'];
             } elseif ($const = JSNUtilsText::getConstant('UPDATE_LINK')) {
                 $ulink = $const;
             }
             throw new Exception(JText::_('JSN_EXTFW_DATA_PRODUCT_VERSION_OUTDATE') . '&nbsp;<a href="' . $ulink . '" class="jsn-link-action">' . JText::_('JSN_EXTFW_GENERAL_UPDATE_NOW') . '</a>');
         }
     } else {
         throw new Exception(JText::_('JSN_EXTFW_DATA_BACKUP_XML_NOT_FOUND'));
     }
     $dataForm = $this->getForm();
     if (!empty($dataForm) && count($dataForm)) {
         foreach ($dataForm as $formId) {
             if (!empty($formId->form_id) && (int) $formId->form_id) {
                 $this->_db->setQuery("DROP TABLE IF EXISTS #__jsn_uniform_submissions_{$formId->form_id}");
                 $this->_db->execute();
             }
         }
     }
     if (JSNUniformHelper::checkTableSql('#__jsn_uniform_submissions') === false) {
         JSNUniformHelper::createTableIfNotExistsSubmissions();
     }
     if (JSNUniformHelper::checkTableSql('#__jsn_uniform_submission_data') === false) {
         JSNUniformHelper::createTableIfNotExistsSubmissionData();
     }
 }
Example #22
0
				</tfoot>
			</table>
			<?php 
} else {
    ?>
			<div class="jsn-bglabel jsn-section-content">
				<?php 
    echo JText::_('JSN_UNIFORM_SUBMISSIONS_SELECT_FORM');
    ?>
				<select name="filter_form_id" onchange="this.form.submit()" class="inputbox" id="filter_form_id">
					<option value="">- <?php 
    echo JText::_('JSN_UNIFORM_SELECT_FORMS');
    ?>
 -</option>
					<?php 
    echo JHtml::_('select.options', JSNUniformHelper::getOptionForms(), 'value', 'text', $formId);
    ?>
				</select>
			</div>
			<?php 
}
?>
		<div>
			<input type="hidden" name="filter_order" value="<?php 
echo $listOrder;
?>
" />
			<input type="hidden" name="old_form_id" value="<?php 
echo $formId;
?>
" />
Example #23
0
 /**
  * Override save method to save form fields to database
  *
  * @return boolean
  */
 public function save($data)
 {
     $formId = !empty($data['filter_form_id']) ? $data['filter_form_id'] : 0;
     $this->_db->setQuery($this->_db->getQuery(true)->select('form_access')->from("#__jsn_uniform_forms")->where('form_id=' . intval($formId)));
     $infoForm = $this->_db->loadObject();
     $user = JFactory::getUser();
     $groupEditSubmision = isset($infoForm->form_access) ? $infoForm->form_access : "";
     $checkEditSubmission = JSNUniformHelper::checkEditSubmission($user->id, $groupEditSubmision);
     if ($checkEditSubmission) {
         if (isset($_POST['submission']) && is_array($_POST['submission']) && isset($_POST['filter_form_id']) && isset($_POST['cid'])) {
             foreach ($_POST['submission'] as $key => $value) {
                 if (is_array($value) && !empty($value['likert'])) {
                     $data = array();
                     foreach ($value as $items) {
                         if (isset($items)) {
                             foreach ($items as $k => $item) {
                                 $data[$k] = $item;
                             }
                         }
                     }
                     $value = $data ? json_encode($data) : "";
                 }
                 $query = $this->_db->getQuery(true);
                 $query->update($this->_db->quoteName("#__jsn_uniform_submission_data"));
                 $query->set("submission_data_value = " . $this->_db->Quote($value));
                 $query->where('submission_id = ' . (int) $_POST['cid']);
                 $query->where('field_id = ' . (int) str_replace("sd_", "", $key));
                 $this->_db->setQuery($query);
                 $this->_db->execute();
             }
         }
     }
     return true;
 }
Example #24
0
<?php

/**
 * @version     $Id: default.php 19013 2012-11-28 04:48:47Z thailv $
 * @package     JSNUniform
 * @subpackage  Form
 * @author      JoomlaShine Team <*****@*****.**>
 * @copyright   Copyright (C) 2012 JoomlaShine.com. All Rights Reserved.
 * @license     GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Websites: http://www.joomlashine.com
 * Technical Support:  Feedback - http://www.joomlashine.com/contact-us/get-support.html
 */
defined('_JEXEC') or die('Restricted access');
$showTitle = false;
$showDes = false;
$app = JFactory::getApplication();
$params = $app->getParams();
$getShowTitle = $this->_input->get('show_form_title');
$getShowDes = $this->_input->get('show_form_description');
if (!empty($getShowTitle) && $getShowTitle == 1) {
    $showTitle = true;
}
if (!empty($getShowDes) && $getShowDes == 1) {
    $showDes = true;
}
if (JSNUniformHelper::checkStateForm($this->_formId)) {
    echo JSNUniformHelper::generateHTMLPages($this->_formId, $this->_formName, '', '', '', $showTitle, $showDes);
}
Example #25
0
 /**
  * Save form submission
  *
  * @param   Array  $post  Post form
  *
  * @return  Messages
  */
 public function save($post)
 {
     $return = new stdClass();
     $submissionsData = array();
     $validationForm = array();
     $requiredField = array();
     $postFormId = isset($post['form_id']) ? $post['form_id'] : "";
     $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_forms')->where("form_id = " . (int) $postFormId));
     $dataForms = $this->_db->loadObject();
     $dataContentEmail = '';
     $fileAttach = "";
     $nameFileByIndentifier = '';
     if (!empty($dataForms->form_captcha)) {
         if ($dataForms->form_captcha == 1) {
             require_once JSN_UNIFORM_LIB_CAPTCHA;
             $recaptchaChallenge = isset($_POST["recaptcha_challenge_field"]) ? $_POST["recaptcha_challenge_field"] : "";
             $recaptchaResponse = isset($_POST["recaptcha_response_field"]) ? $_POST["recaptcha_response_field"] : "";
             $resp = recaptcha_check_answer(JSN_UNIFORM_CAPTCHA_PRIVATEKEY, $_SERVER["REMOTE_ADDR"], $recaptchaChallenge, $recaptchaResponse);
             if (!$resp->is_valid) {
                 $return->error['captcha'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA');
                 return $return;
             }
         } else {
             if ($dataForms->form_captcha == 2) {
                 if (!empty($_POST['form_name']) && !empty($_POST['captcha'])) {
                     $sCaptcha = $_SESSION['securimage_code_value'][$_POST['form_name']] ? $_SESSION['securimage_code_value'][$_POST['form_name']] : "";
                     if (strtolower($sCaptcha) != strtolower($_POST['captcha'])) {
                         $return->error['captcha_2'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA');
                         return $return;
                     }
                 } else {
                     $return->error['captcha_2'] = JText::_('JSN_UNIFORM_ERROR_CAPTCHA');
                     return $return;
                 }
             }
         }
     }
     $dataFormId = isset($dataForms->form_id) ? $dataForms->form_id : 0;
     $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_fields')->where("form_id = " . (int) $postFormId)->order("field_ordering  ASC"));
     $columsSubmission = $this->_db->loadObjectList();
     $fieldClear = array();
     if (isset($dataForms->form_type) && $dataForms->form_type == 1) {
         $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_form_pages')->where("form_id = " . (int) $dataForms->form_id));
         $dataPages = $this->_db->loadObjectList();
         foreach ($dataPages as $index => $page) {
             if ($index > 0) {
                 $contentPage = isset($page->page_content) ? json_decode($page->page_content) : "";
                 foreach ($contentPage as $item) {
                     $fieldClear[] = $item->id;
                 }
             }
         }
     }
     $this->_getActionForm($dataForms->form_post_action, $dataForms->form_post_action_data, $return);
     $fieldEmail = array();
     foreach ($columsSubmission as $colum) {
         if (!in_array($colum->field_id, $fieldClear)) {
             $fieldName = "";
             $fieldName = $colum->field_id;
             $fieldSettings = isset($colum->field_settings) ? json_decode($colum->field_settings) : "";
             $value = "";
             $fieldEmail[$colum->field_id] = $colum->field_identifier;
             if ($colum->field_type != 'static-content' && $colum->field_type != 'google-maps') {
                 if (in_array($colum->field_type, array("single-line-text", "website", "paragraph-text", "country"))) {
                     $postFieldName = isset($post[$fieldName]) ? $post[$fieldName] : '';
                     $postName = get_magic_quotes_gpc() == true || get_magic_quotes_runtime() == true ? stripslashes($postFieldName) : $postFieldName;
                     $value = $postName ? $postName : "";
                 } elseif ($colum->field_type == "choices" || $colum->field_type == "dropdown") {
                     $value = $this->_fieldOthers($post, $fieldSettings, $fieldName);
                 } elseif (in_array($colum->field_type, array("address", "checkboxes", "name", "list", "likert"))) {
                     $value = $this->_fieldJson($post, $colum->field_type, $fieldName, true);
                 } elseif ($colum->field_type == "file-upload") {
                     $value = $this->_fieldUpload($fieldSettings, $fieldName, $colum->field_title, $validationForm, $post);
                 } elseif ($colum->field_type == "email") {
                     $value = $this->_fieldEmail($post, $fieldName, $colum->field_title, $validationForm);
                 } elseif ($colum->field_type == "number") {
                     $value = $this->_fieldNumber($post, $fieldName, $colum->field_title, $validationForm);
                 } else {
                     if ($colum->field_type == "date") {
                         $value = $this->_fieldDate($post, $fieldName, $colum->field_title, $validationForm);
                     } else {
                         if ($colum->field_type == "phone") {
                             $value = $this->_fieldPhone($post, $fieldName, $colum->field_title, $validationForm);
                         } else {
                             if ($colum->field_type == "currency") {
                                 $value = $this->_fieldCurrency($post, $fieldName, $colum->field_title, $validationForm);
                             } else {
                                 if ($colum->field_type == "password") {
                                     $value = $this->_fieldPassword($post, $fieldName, $colum->field_title, $fieldSettings, $validationForm);
                                 }
                             }
                         }
                     }
                 }
                 $submissionsData[] = array('form_id' => $dataFormId, 'field_id' => $colum->field_id, 'submission_data_value' => $value, 'field_type' => $colum->field_type);
                 $keyField = $colum->field_id;
                 $submissions = new stdClass();
                 $submissions->{$keyField} = $value;
                 if (isset($colum->field_type)) {
                     $nameFileByIndentifier[$colum->field_identifier] = $colum->field_title;
                     $contentField = JSNUniformHelper::getDataField($colum->field_type, $submissions, $colum->field_id, $postFormId, false, false, 'email');
                     if ($colum->field_type == "file-upload") {
                         $fileAttach[$colum->field_identifier] = JSNUniformHelper::getDataField($colum->field_type, $submissions, $colum->field_id, $postFormId, false, false, 'fileAttach');
                     }
                     $dataContentEmail[$colum->field_identifier] = $contentField ? str_replace("\n", "<br/>", trim($contentField)) : "<span>N/A</span>";
                     $requiredField[$colum->field_identifier] = $fieldSettings->options->required;
                 }
                 //
                 if (!empty($fieldSettings->options->noDuplicates) && (int) $fieldSettings->options->noDuplicates == 1) {
                     $this->_checkDuplicates($post, $fieldName, $colum->field_title, $validationForm);
                 }
                 if (isset($fieldSettings->options->limitation) && (int) $fieldSettings->options->limitation == 1 && !empty($post[$fieldName])) {
                     if ($fieldSettings->options->limitMin <= $fieldSettings->options->limitMax && $fieldSettings->options->limitMax > 0) {
                         $this->_checkLimitChar($post, $fieldSettings, $fieldName, $colum->field_title, $validationForm);
                     }
                 }
                 if (isset($fieldSettings->options->requiredConfirm) && (int) $fieldSettings->options->requiredConfirm == 1) {
                     $postData = isset($post[$fieldName]) ? $post[$fieldName] : '';
                     $postDataConfirm = isset($post[$fieldName . "_confirm"]) ? $post[$fieldName . "_confirm"] : '';
                     if (isset($fieldSettings->options->required) && (int) $fieldSettings->options->required == 1 && $postData != $postDataConfirm) {
                         $validationForm[$fieldName] = JText::sprintf('JSN_UNIFORM_CONFIRM_FIELD_CONFIRM', $colum->field_title);
                     } else {
                         if (!empty($postData) && !empty($postDataConfirm) && $postData != $postDataConfirm) {
                             $validationForm[$fieldName] = JText::sprintf('JSN_UNIFORM_CONFIRM_FIELD_CONFIRM', $colum->field_title);
                         }
                     }
                 }
                 if (isset($fieldSettings->options->required) && (int) $fieldSettings->options->required == 1 && (int) $fieldSettings->options->hideField != 1) {
                     switch ($colum->field_type) {
                         case "name":
                             $postFieldName = isset($post['name'][$fieldName]) ? $post['name'][$fieldName] : '';
                             if ($postFieldName['first'] == "" && $postFieldName['last'] == "" && $postFieldName['suffix'] == "") {
                                 $validationForm['name'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                             }
                             break;
                         case "address":
                             $postAddress = $post['address'][$fieldName];
                             if ($postAddress['street'] == "" && $postAddress['line2'] == "" && $postAddress['city'] == "" && $postAddress['code'] == "" && $postAddress['state'] == "") {
                                 $validationForm['address'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                             }
                             break;
                         case "email":
                             $postFieldEmail = isset($post[$fieldName]) ? $post[$fieldName] : '';
                             $postEmail = get_magic_quotes_gpc() == true || get_magic_quotes_runtime() == true ? stripslashes($postFieldEmail) : $postFieldEmail;
                             $regex = '/^[_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{2,6})$/';
                             if (!preg_match($regex, $postEmail)) {
                                 $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_INVALID');
                             }
                             break;
                         case "number":
                             if ($post['number'][$fieldName] == "") {
                                 $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                             } else {
                                 $postNumber = $post['number'][$fieldName]['value'];
                                 $postNumberDecimal = $post['number'][$fieldName]['decimal'];
                                 $regex = '/^[0-9]+$/';
                                 $checkNumber = false;
                                 if ($postNumber != "") {
                                     if (preg_match($regex, $postNumber)) {
                                         $checkNumber = true;
                                     }
                                 }
                                 if ($postNumberDecimal != "") {
                                     if (preg_match($regex, $postNumberDecimal)) {
                                         $checkNumber = true;
                                     }
                                 }
                                 if (!$checkNumber) {
                                     $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                                 }
                             }
                             break;
                         case "website":
                             $postWebsite = isset($post[$fieldName]) ? $post[$fieldName] : '';
                             $regex = "/^((http|https|ftp):\\/\\/|www([0-9]{0,9})?\\.)?([a-zA-Z0-9][a-zA-Z0-9_-]*(?:\\.[a-zA-Z0-9][a-zA-Z0-9_-]*)+):?(\\d+)?\\/?/i";
                             if (!preg_match($regex, $postWebsite)) {
                                 $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_INVALID');
                             }
                             break;
                         case "file-upload":
                             if (empty($_FILES[$fieldName]['name'])) {
                                 $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                             }
                             break;
                         case "date":
                             if (isset($fieldSettings->options->enableRageSelection) && $fieldSettings->options->enableRageSelection == "1") {
                                 if ($post['date'][$fieldName]['date'] == "" || $post['date'][$fieldName]['daterange'] == "") {
                                     $validationForm['date'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                                 }
                             } else {
                                 if ($post['date'][$fieldName]['date'] == "") {
                                     $validationForm['date'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                                 }
                             }
                             break;
                         case "currency":
                             if ($post['currency'][$fieldName]['value'] == "") {
                                 $validationForm['currency'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                             }
                             break;
                         case "phone":
                             if (isset($fieldSettings->options->format) && $fieldSettings->options->format == "3-field") {
                                 if ($post['phone'][$fieldName]['one'] == "" || $post['phone'][$fieldName]['two'] == "" || $post['phone'][$fieldName]['three'] == "") {
                                     $validationForm['phone'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                                 }
                             } else {
                                 if ($post['phone'][$fieldName]['default'] == "") {
                                     $validationForm['phone'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                                 }
                             }
                             break;
                         case "password":
                             if (count($post['password'][$fieldName]) > 1) {
                                 if ($post['password'][$fieldName][0] == "" || $post['password'][$fieldName][1] == "") {
                                     $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                                 } else {
                                     if ($post['password'][$fieldName][0] != "" && $post['password'][$fieldName][1] != "" && $post['password'][$fieldName][0] != $post['password'][$fieldName][1]) {
                                         $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_PASSWORD_CONFIRM');
                                     }
                                 }
                             } else {
                                 if ($post['password'][$fieldName][0] == "") {
                                     $validationForm['password'][$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                                 }
                             }
                             break;
                         default:
                             if (isset($post[$fieldName]) && $post[$fieldName] == "") {
                                 $validationForm[$fieldName] = JText::_('JSN_UNIFORM_CONFIRM_FIELD_CANNOT_EMPTY');
                             }
                             break;
                     }
                 }
             } else {
                 if (isset($colum->field_type) && $colum->field_type != 'file-upload' && $colum->field_type != 'google-maps') {
                     $nameFileByIndentifier[$colum->field_identifier] = $colum->field_title;
                     $dataContentEmail[$colum->field_identifier] = $fieldSettings->options->value;
                 }
             }
         }
     }
     if (!$validationForm) {
         $this->_save($dataForms, $return, $post, $submissionsData, $dataContentEmail, $nameFileByIndentifier, $requiredField, $fileAttach);
         return $return;
     } else {
         $return->error = $validationForm;
         return $return;
     }
 }
Example #26
0
 $dataItem = array();
 for ($i = 0; $i < count($fieldIdentifier); $i++) {
     if (in_array($fieldIdentifier[$i], $arrayField)) {
         $dataItem[] = JText::_($fieldTitle[$i]);
     }
 }
 $dataItem[] = JText::_("JGRID_HEADING_ID");
 $data[] = $dataItem;
 if (is_array($arrayField)) {
     if ($this->_dataExport) {
         foreach ($this->_dataExport as $i => $item) {
             $dataItem = array();
             foreach ($arrayField as $j => $field) {
                 $contentField = "";
                 if (isset($fieldType[$field])) {
                     $contentField = JSNUniformHelper::getDataField($fieldType[$field], $item, $field, $formId, false, false, 'export');
                     $contentField = $contentField ? $contentField : "";
                     if ($field == 'submission_created_by' && !$item->{$field}) {
                         $contentField = isset($listUser[$item->{$field}]) ? $listUser[$item->{$field}] : "Guest";
                     }
                     $dataItem[] = $contentField;
                 }
             }
             $dataItem[] = $item->submission_id;
             $data[] = $dataItem;
         }
     }
 }
 if (isset($_GET['e']) && $_GET['e'] == "excel") {
     include_once JSN_UNIFORM_LIB_PHPEXCEL;
     // generate file (constructor parameters are optional)
Example #27
0
 /**
  * get field select view
  *
  * @return array
  */
 public function getViewField()
 {
     $resultFields = array();
     $positionField = "";
     $listViewField = $this->escape($this->_state->get('filter.list_view_field'));
     $listViewField = get_magic_quotes_gpc() == true || get_magic_quotes_runtime() == true ? stripslashes($listViewField) : $listViewField;
     $positionField = $this->escape($this->_state->get('filter.position_field'));
     $configGetPosition = JSNUniformHelper::getPositionFields($this->_state->get('filter.filter_form_id'));
     //$fieldsForms       = $this->get('FieldsForm');
     $fieldsDatas = JSNUniformHelper::getFormData();
     $fieldsForms = array();
     $dataPages = $this->get('DataPages');
     foreach ($dataPages as $index => $page) {
         $pageContent = isset($page->page_content) ? json_decode($page->page_content) : "";
         foreach ($pageContent as $itemPage) {
             if (!empty($itemPage->id)) {
                 $fieldsForms[] = $itemPage;
             }
         }
     }
     foreach ($fieldsForms as $fieldsForm) {
         if (isset($fieldsForm->type) && $fieldsForm->type != 'static-content' && $fieldsForm->type != 'google-maps') {
             $resultFields['identifier'][] = 'sd_' . $fieldsForm->id;
             $resultFields['title'][] = $fieldsForm->label;
             $resultFields['type']['sd_' . $fieldsForm->id] = $fieldsForm->type;
             $resultFields['sort'][] = 'sd.sd_' . $fieldsForm->id;
             $resultFields['styleclass'][] = "field";
         }
     }
     foreach ($fieldsDatas as $fieldsData) {
         if (!in_array($fieldsData->Field, array('submission_data_id', 'submission_id', 'form_id', 'user_id', 'submission_state', 'submission_country_code', 'submission_browser_version', 'submission_browser_agent'))) {
             $resultFields['identifier'][] = $fieldsData->Field;
             $resultFields['title'][] = 'JSN_UNIFORM_' . strtoupper($fieldsData->Field);
             $resultFields['sort'][] = 'sb.' . $fieldsData->Field;
             $resultFields['type'][$fieldsData->Field] = $fieldsData->Type;
             $resultFields['styleclass'][] = "field";
         }
     }
     if ($configGetPosition) {
         $configGetPosition = json_decode($configGetPosition->value);
     }
     if ($positionField) {
         $positionField = explode(",", $positionField);
     } elseif ($configGetPosition && $configGetPosition->identifier) {
         $positionField = array_merge($configGetPosition->identifier, $resultFields['identifier']);
         $positionField = array_unique($positionField);
     }
     if (!$listViewField && $configGetPosition) {
         $listViewField = $configGetPosition->field_view;
     }
     if (!$listViewField) {
         $check = true;
         $i = 0;
         while ($check) {
             $j = 0;
             foreach ($resultFields['type'] as $rField) {
                 if (isset($rField) && $rField != 'static-content' && $rField != 'google-maps') {
                     if (strpos($resultFields['identifier'][$j], "sd_") !== false) {
                         $listViewField[] = '&quot;' . $resultFields['identifier'][$j] . '&quot;';
                     }
                     if ($j == 2) {
                         $listViewField[] = '&quot;submission_country&quot;';
                         $listViewField[] = '&quot;submission_created_by&quot;';
                         $listViewField[] = '&quot;submission_created_at&quot;';
                         $listViewField = implode(",", $listViewField);
                         $check = false;
                         break;
                     }
                 }
                 $j++;
             }
             if ($i == 20) {
                 $check = false;
             }
             $i++;
         }
     }
     if (!empty($positionField)) {
         $resultPositionFields = array();
         foreach ($positionField as $pField) {
             for ($i = 0; $i < count($resultFields['identifier']); $i++) {
                 if ($pField == $resultFields['identifier'][$i] && $resultFields['type'][$resultFields['identifier'][$i]] != 'static-content' && $resultFields['type'][$resultFields['identifier'][$i]] != 'google-maps') {
                     $resultPositionFields['identifier'][] = $resultFields['identifier'][$i];
                     $resultPositionFields['title'][] = $resultFields['title'][$i];
                     $resultPositionFields['sort'][] = $resultFields['sort'][$i];
                     $resultPositionFields['styleclass'][] = $resultFields['styleclass'][$i];
                     $resultPositionFields['type'][$resultFields['identifier'][$i]] = $resultFields['type'][$resultFields['identifier'][$i]];
                 }
             }
         }
         $result = array('fields' => $resultPositionFields, 'field_view' => $listViewField);
     } else {
         $result = array('fields' => $resultFields, 'field_view' => $listViewField);
     }
     JSNUniformHelper::setPositionFields($this->_state->get('filter.filter_form_id'), $result);
     return $result;
 }
Example #28
0
            ?>
							<tr class="row<?php 
            echo $i % 2;
            ?>
">
								<?php 
            if (is_array($arrayField)) {
                foreach ($arrayField as $j => $field) {
                    $contentField = "";
                    if (isset($fieldType[$field])) {
                        $contentField = JSNUniformHelper::getDataField($fieldType[$field], $item, $field, $formId, true, true, 'list');
                        $contentField = $contentField ? str_replace("\n", "<br/>", trim($contentField)) : "<span>N/A</span>";
                        if ($j < 1) {
                            $contentField = '<td><a href="' . JRoute::_('index.php?option=com_uniform&view=submission&submission_id=' . (int) $item->submission_id) . '">' . $contentField . '</a> </td>';
                        } elseif ($field == 'submission_created_by' && !$item->{$field}) {
                            $contentField = isset($item->{$field}) ? JSNUniformHelper::getUserNameById($item->{$field}) : "Guest";
                            $contentField = "<td>{$contentField}</td>";
                        } else {
                            $contentField = "<td>{$contentField}</td>";
                        }
                        echo $contentField;
                    }
                }
            }
            ?>
							</tr>
								<?php 
        }
    } else {
        ?>
						<tr>
Example #29
0
" id="jform_form_content" name="jform[form_content]">
		</div>
	</div>
</div>
</div>
<div id="form-action" class="form-horizontal">
	<div class="row-fluid">
		<div class="span6">
			<fieldset id="email">
				<legend>
					<?php 
echo JText::_('JSN_UNIFORM_FORM_EMAIL_NOTIFICATION');
?>
				</legend>
				<?php 
echo JSNUniformHelper::getListEmailNotification($this->_fromEmail);
?>
				<div class="control-group jsn-items-list-container">
					<label class="control-label jsn-label-des-tipsy" original-title="<?php 
echo JText::_('JSN_UNIFORM_SELECT_EMAIL_FORM_FIELD');
?>
">
						<?php 
echo JText::_('JSN_UNIFORM_SEND_TO_SUBMITTER');
?>
					</label>

					<div class="controls">
						<button class="btn btn-icon pull-right " id="btn_email_submit" original-title="<?php 
echo JText::_('JSN_UNIFORM_EMAIL_CONTENT');
?>
Example #30
0
 /**
  * Method to duplicate modules.
  *
  * @param   array  &$pks  An array of primary key IDs.
  *
  * @return  boolean  True if successful.
  *
  * @since   1.6
  * @throws  Exception
  */
 public function duplicate(&$pks)
 {
     // Initialise variables.
     $user = JFactory::getUser();
     $db = $this->getDbo();
     // Access checks.
     if (!$user->authorise('core.create', 'com_uniform')) {
         throw new Exception(JText::_('JERROR_CORE_CREATE_NOT_PERMITTED'));
     }
     $table = $this->getTable();
     $checkCreate = true;
     foreach ($pks as $pk) {
         $edition = defined('JSN_UNIFORM_EDITION') ? JSN_UNIFORM_EDITION : "free";
         if (strtolower($edition) == "free") {
             $dataListForm = JSNUniformHelper::getForms();
             if (count($dataListForm) >= 3) {
                 $checkCreate = false;
             }
         }
         if ($checkCreate) {
             if ($table->load($pk, true)) {
                 // Reset the id to create a new record.
                 $table->form_id = 0;
                 // Alter the title.
                 $m = null;
                 if (preg_match('#\\((\\d+)\\)$#', $table->form_title, $m)) {
                     $table->form_title = preg_replace('#\\(\\d+\\)$#', '(' . ($m[1] + 1) . ')', $table->form_title);
                 } else {
                     $table->form_title .= ' (2)';
                 }
                 // Unpublish duplicate module
                 $table->form_state = 0;
                 $table->form_submission_cout = 0;
                 $table->form_last_submitted = '';
                 if (!$table->check() || !$table->store()) {
                     throw new Exception($table->getError());
                 }
                 // Email
                 $query = $db->getQuery(true);
                 $query->select('*');
                 $query->from('#__jsn_uniform_emails');
                 $query->where('form_id=' . (int) $pk);
                 $this->_db->setQuery((string) $query);
                 $emails = $this->_db->loadObjectList();
                 foreach ($emails as $email) {
                     $email->email_id = 0;
                     $email->form_id = $table->form_id;
                     $tableEmail = JTable::getInstance('JsnEmail', 'JSNUniformTable');
                     $tableEmail->bind($email);
                     if (!$tableEmail->store()) {
                         $this->setError($tableEmail->getError());
                     }
                 }
                 //Email template
                 $query = $db->getQuery(true);
                 $query->select('*');
                 $query->from('#__jsn_uniform_templates');
                 $query->where('form_id=' . (int) $pk);
                 $this->_db->setQuery((string) $query);
                 $templates = $this->_db->loadObjectList();
                 foreach ($templates as $template) {
                     $template->template_id = 0;
                     $template->form_id = $table->form_id;
                     $tableTemplate = JTable::getInstance('JSNTemplate', 'JSNUniformTable');
                     $tableTemplate->bind($template);
                     if (!$tableTemplate->store()) {
                         $this->setError($tableTemplate->getError());
                     }
                 }
                 //Page and Field
                 $query = $db->getQuery(true);
                 $query->select('*');
                 $query->from('#__jsn_uniform_form_pages');
                 $query->where('form_id=' . (int) $pk);
                 $query->order("page_id ASC");
                 $this->_db->setQuery((string) $query);
                 $pages = $this->_db->loadObjectList();
                 foreach ($pages as $page) {
                     $dataField = array();
                     $fields = json_decode($page->page_content);
                     $pageTemplate = json_decode($page->page_template);
                     $formPages = array();
                     $parsedFields = array();
                     foreach ($fields as $index => $item) {
                         $tableField = JTable::getInstance('JsnField', 'JSNUniformTable');
                         $tableField->bind(array('form_id' => $table->form_id, 'field_type' => $item->type, 'field_identifier' => $item->identify, 'field_title' => $item->label, 'field_instructions' => isset($item->instruction) ? $item->instruction : null, 'field_position' => $item->position, 'field_ordering' => $index));
                         if (!$tableField->store()) {
                             $this->setError($tableField->getError());
                         }
                         $fieldSettings = $item;
                         $fieldSettings->id = $tableField->field_id;
                         $tableUpdateField = JTable::getInstance('JsnField', 'JSNUniformTable');
                         $tableUpdateField->bind(array('field_settings' => $fieldSettings, 'field_id' => $tableField->field_id));
                         if (!$tableUpdateField->store()) {
                             $this->setError($tableUpdateField->getError());
                         }
                         $parsedFields[] = $fieldSettings;
                     }
                     $formPages['page_id'] = 0;
                     $formPages['page_title'] = $page->page_title;
                     $formPages['page_container'] = $page->page_container;
                     $formPages['form_id'] = $table->form_id;
                     $formPages['page_content'] = isset($parsedFields) ? json_encode($parsedFields) : "";
                     $tablePage = JTable::getInstance('JsnPage', 'JSNUniformTable');
                     $tablePage->bind($formPages);
                     if (!$tablePage->store()) {
                         $this->setError($tablePage->getError());
                     }
                 }
             } else {
                 throw new Exception($table->getError());
             }
         }
     }
     if (!$checkCreate) {
         $msg = JText::sprintf('JSN_UNIFORM_YOU_HAVE_REACHED_THE_LIMITATION_OF_3_FORM_IN_FREE_EDITION', 0) . ' <a class="jsn-link-action" href="index.php?option=com_uniform&view=upgrade">' . JText::_("JSN_UNIFORM_UPGRADE_EDITION") . '</a>';
         throw new Exception($msg);
     }
     return true;
 }