/** * create a select dropdown * * @param $name string field name * @param $selected string/array field value(s) * @param $attributes array additional input attributes * @param $id string * @param $translate boolean apply JText? * @param $addTD boolean wrap the result in <td> tags if true * @param $styleTD string valid css style string e.g. 'font-weight:bold;' to td */ function createSelect($name, $options, $selected = '', $attributes = array(), $id = false, $translate = false, $addTD = true, $attribTD = array()) { $id = ChronoContactHelperPlugin::createId($name, $id); if (!is_array($selected)) { $selected = explode(', ', $selected); } // if the selection is empty add a null option to the beginning of the options list if (!empty($selected)) { $null_option = array('null' => JHTML::_('select.option', JText::_('--?--'))); $options = array_merge($null_option, $options); } $return = JHTML::_('select.genericlist', $options, $name, JArrayHelper::toString($attributes), 'value', 'text', $selected, $id, $translate); if ($addTD) { $return = ChronoContactHelperPlugin::wrapTD($return, $attribTD); } return $return; }
function save_conf($option) { global $mainframe; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); $helper->save_conf($option); }
/** * The function that will be executed when the form is submitted * */ function onsubmit($option, $params, $row) { global $mainframe; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); $doc =& JFactory::getDocument(); $doc->addStyleDeclaration("div.debug {border:1px solid red; padding:3px; margin-bottom:3px;}"); $mainframe->enqueuemessage('$_POST: ' . print_r($_POST, true)); $messages = array(); /*********do the before onsubmit code**********/ if (!empty($row->extra4)) { eval("?>" . $row->extra4); } $url_values = array(); /// add main fields if (trim($row->extra2)) { $extras2 = explode("\n", $row->extra2); foreach ($extras2 as $extra2) { $values = array(); $values = explode("=", $extra2); if ($values[1]) { $v = urlencode(trim($values[1])); $url_values[$v] = JRequest::getVar(trim($values[0]), '', 'post', 'string', ''); } } } if (trim($row->extra1)) { $extras = explode("\n", $row->extra1); foreach ($extras as $extra) { // Note: accept only the first parameter pair on each line $values = explode("=", $extra, 2); if (isset($values[1])) { $url_values[$values[0]] = trim($values[1]); } } } $query = JURI::buildQuery($url_values); $uri = $params->get('target_url') . '?' . $query; $parts['query'] = $query; $parts['scheme'] = 'http'; $parts['host'] = 'bobjanes.com'; //$parts['host'] = $params->get('target_url'); //$uri = JURI::toString($parts); $MyForm =& CFChronoForm::getInstance(); $MyForm->formrow->redirecturl = $uri; $messages[] = '<b>cf_redirect debug info</b>'; $messages[] = '$url: ' . print_r($uri, true); $messages[] = '$_POST: ' . print_r($_POST, true); /* * Build query into url and set CF redirect url */ $helper->showCFDebugMessage('Redirect URL set'); if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } }
function onsubmit($option, $params, $row) { global $mainframe; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); $messages[] = 'Inside cf_Joomla_registration::onSubmit()'; // Check for request forgeries //JRequest::checkToken() or die( 'Invalid Token' ); // Get required system objects $user = clone JFactory::getUser(); $pathway =& $mainframe->getPathway(); $config =& JFactory::getConfig(); $authorize =& JFactory::getACL(); $document =& JFactory::getDocument(); $language =& JFactory::getLanguage(); $language->load('com_user'); if ($row->form_id) { $formname = CFChronoForm::getFormName($row->form_id); } else { $formname = JRequest::getVar('chronoformname'); } $MyForm =& CFChronoForm::getInstance($formname); $MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id); // If user registration is not allowed, show 403 not authorized. $usersConfig =& JComponentHelper::getParams('com_users'); if ($usersConfig->get('allowUserRegistration') == '0') { if ($params->get('overrideJallowUserRegistration', '0') != '1') { JError::raiseError(403, JText::_('Access Forbidden')); return; } } // Initialize new usertype setting $newUsertype = false; //$usersConfig->get( 'new_usertype' ); if (!$newUsertype) { if ($params->get('new_usertype', 'Registered')) { $newUsertype = $params->get('new_usertype', 'Registered'); } else { $newUsertype = 'Registered'; } } // execute Extra Code before if (!empty($row->extra4)) { eval("?>" . $row->extra4); } // Bind the post array to the user object $post = JRequest::get('post'); $post['username'] = JRequest::getVar($params->get('username'), '', 'post', 'username'); $post['name'] = JRequest::getVar($params->get('name'), '', 'post', 'name'); $post['email'] = JRequest::getVar($params->get('email'), '', 'post', 'email'); if (!$params->get('createpassword')) { $post['password'] = JRequest::getVar($params->get('pass'), '', 'post', 'string'); $post['password2'] = JRequest::getVar($params->get('vpass'), '', 'post', 'string'); if ($params->get('vpass') && $post['password'] != $post['password2']) { $MyPlugins->cf_joomla_registration['errors'] = JText::_('Passwords do not match'); $messages[] = JText::_('Passwords do not match'); if ($params->get('showmessages')) { //$mainframe->enqueuemessage(JText::_('Passwords do not match'), 'error'); $MyForm->addErrorMsg(JText::_('Passwords do not match')); } if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } // remove the password values from display $post['password'] = $post[$params->get('pass')] = ''; $post['password2'] = $post[$params->get('vpass')] = ''; //$MyForm->showForm($MyForm->formrow->name, $post); return false; } else { if (!trim($post['password']) && !trim($post['password'])) { $MyPlugins->cf_joomla_registration['errors'] = JText::_('Password required'); if ($params->get('showmessages')) { //$mainframe->enqueuemessage(JText::_('Passwords do not match'), 'error'); $MyForm->addErrorMsg(JText::_('Password required')); } return false; } else { } } } else { jimport('joomla.user.helper'); $post['password'] = $post['password2'] = JUserHelper::genRandomPassword(); } $messages[] = '$post: ' . print_r($post, true); if (!$user->bind($post, 'usertype')) { JError::raiseError(500, $user->getError()); } // Set some initial user values $user->set('id', 0); $user->set('usertype', ''); $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO')); // TODO: Should this be JDate? $user->set('registerDate', date('Y-m-d H:i:s')); // If user activation is turned on, we need to set the activation information $useractivation = $usersConfig->get('useractivation'); if ($useractivation) { jimport('joomla.user.helper'); $user->set('activation', JUtility::getHash(JUserHelper::genRandomPassword())); $user->set('block', '1'); } // If there was an error with registration, set the message and display form if (!$user->save()) { $MyPlugins->cf_joomla_registration['errors'] = JText::_($user->getError()); $messages[] = JText::_($user->getError()); if ($params->get('showmessages')) { //$mainframe->enqueuemessage(JText::_( $user->getError()), 'error'); $MyForm->addErrorMsg(JText::_($user->getError())); } if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } // remove the password values from display $post['password'] = $post[$params->get('pass')] = ''; $post['password2'] = $post[$params->get('vpass')] = ''; //$MyForm->showForm($MyForm->formrow->name, $post); return false; } $MyPlugins->cf_joomla_registration['user'] = $user; JRequest::setVar('cf_user_id', $user->id); // Send registration confirmation mail $password = JRequest::getString($params->get('pass'), '', 'post'); //Disallow control chars in the password $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password); if (substr($params->get('emailuser'), 0, 6) != "custom") { $this->_sendMail($user, $password, $params->get('emailuser'), $params->get('emailadmins')); } else { $MyForm =& CFChronoForm::getInstance($formname); $MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id); $emailid = (int) str_replace("custom", "", $params->get('emailuser')); $MyFormEmails->emails[$emailid - 1]->enabled = 1; $MyFormEmails->emails[$emailid - 1]->template = str_replace("{vlink}", JURI::base() . "index.php?option=com_user&task=activate&activation=" . $user->get('activation'), $MyFormEmails->emails[$emailid - 1]->template); $MyEmail = array($MyFormEmails->emails[$emailid - 1]); $MyFormEmails->sendEmails($MyForm, $MyEmail); } // Everything went fine, set relevant message depending upon user activation state and display message $MyPlugins->cf_joomla_registration['complete'] = true; if ($params->get('joomlastatus')) { if ($useractivation) { echo $message = JText::_('REG_COMPLETE_ACTIVATE'); } else { if ($params->get('autologin')) { echo $message = JText::_('REG_COMPLETE'); } } } if ($params->get('autologin')) { $credentials = array(); $credentials['username'] = $post['username']; $credentials['password'] = JRequest::getVar($params->get('pass'), '', 'post', 'string', JREQUEST_ALLOWRAW); $mainframe->login($credentials); } // execute Extra Code before if (!empty($row->extra5)) { eval("?>" . $row->extra5); } if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } }
/** * The function that will be executed when the form is submitted * */ function onsubmit($option, $params, $row) { global $mainframe; if (!function_exists('curl_init')) { $mainframe->enqueuemessage("CURL problem : the CURL function was not found on this server.<br />\n Sorry, but the CURL plugin cannot be used on this site as it is currently set up.", 'error'); return; } require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); $doc =& JFactory::getDocument(); $doc->addStyleDeclaration("div.debug {border:1px solid red; padding:3px; margin-bottom:3px;}"); $messages = array(); /*********do the before onsubmit code**********/ if (!empty($row->extra4)) { eval("?>" . $row->extra4); } $curl_values = array(); /// add main fields if (trim($row->extra2)) { $extras2 = explode("\n", $row->extra2); foreach ($extras2 as $extra2) { $values = array(); $values = explode("=", $extra2); if ($values[1]) { $v = urlencode(trim($values[1])); $curl_values[$v] = JRequest::getVar(trim($values[0]), '', 'post', 'string', ''); } } } if (trim($row->extra1)) { $extras = explode("\n", $row->extra1); foreach ($extras as $extra) { // Note: accept only the first parameter pair on each line $values = explode("=", $extra, 2); $curl_values[$values[0]] = trim($values[1]); } } $query = JURI::buildQuery($curl_values); $messages[] = '<b>cf_CURL debug info</b>'; $messages[] = '$curl_values: ' . print_r($query, true); $messages[] = '$params->target_url: ' . print_r($params->get('target_url'), true); $ch = curl_init($params->get('target_url')); $messages[] = '$ch: ' . print_r($ch, true); curl_setopt($ch, CURLOPT_HEADER, $params->get('header_in_response')); // set to 0 to eliminate header info from response curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1) curl_setopt($ch, CURLOPT_POSTFIELDS, $query); // use HTTP POST to send form data curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $response = curl_exec($ch); //execute post and get results curl_close($ch); $messages[] = 'CURL response: ' . print_r($response, true); $helper->showCFDebugMessage('CURL transaction executed'); /*********do the after onsubmit code**********/ if (!empty($row->extra5)) { eval("?>" . $row->extra5); } if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } }
function save_conf($option) { require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); $helper->save_conf($option); }
function show_conf($row, $id, $form_id, $option) { global $mainframe; require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); // identify and initialise the parameters used in this plugin $params_array = array('debugging' => '0', 'languages' => '', 'default_language' => ''); $params = $helper->loadParams($row, $params_array); $messages[] = '$params: ' . print_r($params, true); if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } $tags = explode(',', $params->get('languages')); ?> <form action="index2.php" method="post" name="adminForm" id="adminForm" class="adminForm"> <?php echo $pane->startPane("multilanguage"); /* echo $pane->startPanel( 'Multi Language settings', "settings" ); ?> <table border='0' cellpadding='3' cellspacing='0' class='cf_table' > <?php $input = $helper->createHeaderTD('Configure the plugin', '', true, array('colspan' => '4', 'class' => 'cf_header')); echo $helper->wrapTR($input); $tooltip = "Your list of supported languages, in 2-2 letters form e.g. en-GB,fr-FR,es-ES"; $input = $helper->createInputTD("Languages supported", "params[languages]", $params->get('languages'), '', $attribs['input'], $tooltip); echo $helper->wrapTR($input, array('class' => 'cf_config')); $tooltip = "Default language which will run when the current site language is not supported e.g. en-GB"; $input = $helper->createInputTD("Default language", "params[default_language]", $params->get('default_language'), '', $attribs['input'], $tooltip); echo $helper->wrapTR($input, array('class' => 'cf_config')); ?> </table> <?php echo $pane->endPanel(); */ echo $pane->startPanel("Languages 1-5", 'Languages2'); ?> <table border="0" cellpadding="3" cellspacing="0" class='cf_table' > <?php $tooltip = "Add your language translations here!"; for ($i = 1; $i <= 2; $i++) { $extra = 'extra' . $i; $tag_name = ''; if (!empty($tags[$i - 1])) { $tag_name = $tags[$i - 1]; } $input = $helper->createTextareaTD('Language Strings: ' . $tag_name, $extra, $row->{$extra}, $attribs['textarea'], $tooltip); echo $helper->wrapTR($input, array('class' => 'cf_config')); } ?> </table> <?php echo $pane->endPanel(); /* echo $pane->startPanel( "Languages 6-10", 'Languages3' ); ?> <table border="0" cellpadding="3" cellspacing="0" class='cf_table' > <?php for ( $i = 6; $i <= 10; $i++ ) { $extra = 'extra'.$i; $input = $helper->createTextareaTD('Language Strings', 'params['.$extra.']', $params->get($extra), $attribs['textarea'], $tooltip ); echo $helper->wrapTR($input, array('class' => 'cf_config')); } ?> </table> <?php echo $pane->endPanel(); */ /* echo $pane->startPanel( "Help", 'Legend3' ); ?> <table border="0" cellpadding="3" cellspacing="0" class='cf_table' > <?php $input = $helper->createHeaderTD('How to use the Multi Language plugin', '', true, array('colspan' => '4', 'class' => 'cf_header')); echo $helper->wrapTR($input); ?> <tr> <td colspan='4' style='border:1px solid silver; padding:6px;'> <div>The plugin allows you to create multi-language forms in ChronoForms.</div> <div>The plugin works by checking the current language from the Joomla settings and then replacing 'key phrases' in the form html with the equivalent you have defined for that language.</div> <ul><li>In the Settings tab enter a list of the languages that you want to support using the 'country code'-'region code' format: en-GB, fr-FR </li> <li>Enter one of these language codes as the default value to be used if there isn't a definition for a language in use.</li> <li>On the second and third tabs are a series of text areas in which you can enter your language translations. Note that after the plugin is saved language tags will show up by the corresponding box names.</li> <li>In each box enter each of the 'key phrases' and the language equivalents e.g. in en-GB: 'Required field=This field is required'; in fr-FR: 'Requred field=Ce champ est obligatoire'; and in nl-NL: Requred field=Dit veld is verplicht'.</li> <li>Notice that each entry takes the form Key phrase=Translated expression. Don't leave spaces around the '=' and don't add quotes around either part of the entry.</li> <li>Start each new 'key phrase' on a new line.</li> <li>In your form html make sure that the 'key phrase' is entered in exactly the same way as in the plugin e.g. <input . . . title='Required field' . . . /></li> </ul> <div>Note that you can use Key phrases for any text in your for html.</div> <ul><li>For label text.</li> <li>For title entries to show validation error messages.</li> <li>For image names to show language specific images e.g 'Submit_image=submit_img_fr.jpg'</li> <li>For short body text - remember that the entry has to go onto a single line in the text area.</li></ul> <div>This version of the multi-language plugin will also translate ChronoForms errors so it can be used, for example, with the AntiSpam error message.</div> </td> </tr> </table> <?php echo $pane->endPanel(); */ echo $pane->endPane(); $hidden_array = array('id' => $id, 'form_id' => $form_id, 'name' => $this->plugin_name, 'event' => $this->event, 'option' => $option, 'task' => 'save_conf'); //$hidden_array['params[onsubmit]'] = 'before_email'; echo $helper->createHiddenArray($hidden_array); ?> </form> <?php }
function onsubmit($option, $params, $row) { global $mainframe; //echo "XXX"; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php'; $helper = new ChronoContactHelperPlugin(); if ($row->form_id) { $formname = CFChronoForm::getFormName($row->form_id); } else { $formname = JRequest::getVar('chronoformname'); } $MyForm =& CFChronoForm::getInstance($formname); $MyUploads =& CFUploads::getInstance($MyForm->formrow->id); $session =& JFactory::getSession(); $pluginrow = $row; $newposted = JRequest::get('post', JREQUEST_ALLOWRAW); $oldposted = array(); if ($session->get('chrono_formpages_data_' . $formname, array(), md5('chrono'))) { $oldposted = $session->get('chrono_formpages_data_' . $formname, array(), md5('chrono')); } if ($session->get('chrono_formpages_files_' . $formname, array(), md5('chrono'))) { $MyUploads->attachments = $session->get('chrono_formpages_files_' . $formname, array(), md5('chrono')); } $posted = array_merge($oldposted, $newposted); $messages[] = 'Posted: ' . print_r($posted, true); $messages[] = 'Files: ' . print_r($MyUploads->attachments, true); JRequest::set($posted, 'post'); $session->set('chrono_formpages_data_' . $formname, $posted, md5('chrono')); $pages = explode(",", $params->get('formsnames')); $current_step = $session->get('chrono_step_' . $formname, '', md5('chrono')); $messages[] = 'Current step: ' . print_r($current_step, true); if ($params->get('debugging')) { $helper->showPluginDebugMessages($messages); } if (JRequest::getVar($params->get('finalbuttonname'))) { $current_step = 'end'; } if ($current_step != 'end') { if ($current_step) { $newForm =& CFChronoForm::getInstance(trim($pages[$current_step - 1])); $newForm->formrow->submiturl = $newForm->getAction($MyForm->formrow->name); $newForm->formrow->html = $newForm->formrow->html . '<input type="hidden" name="cfformstep" value="' . $current_step . '" />'; $newForm->submitForm($newForm->formrow->name, $posted); $newUploads =& CFUploads::getInstance($newForm->formrow->id); $MyUploads->attachments = array_merge($MyUploads->attachments, $newUploads->attachments); $session->set('chrono_formpages_files_' . $formname, $MyUploads->attachments, md5('chrono')); //check if the previous form submission completed successfully if ($newForm->submission_complete) { if ($current_step == (int) $params->get('stepscount')) { $session->set('chrono_step_' . $formname, 'end', md5('chrono')); //$MyForm->submitForm($MyForm->formrow->name); return; } $nextForm =& CFChronoForm::getInstance(trim($pages[$current_step])); $nextForm->formrow->submiturl = $nextForm->getAction($MyForm->formrow->name); $nextForm->formrow->html = $nextForm->formrow->html . '<input type="hidden" name="cfformstep" value="' . $current_step . '" />'; $session->set('chrono_step_' . $formname, $current_step + 1, md5('chrono')); $nextForm->showForm($nextForm->formrow->name, $posted); } } else { $newForm =& CFChronoForm::getInstance(trim($pages[0])); $newForm->formrow->submiturl = $newForm->getAction($MyForm->formrow->name); $session->set('chrono_step_' . $formname, 1, md5('chrono')); $newForm->showForm($newForm->formrow->name, $posted); } //exit the form routine $MyForm->stoprunning = true; return; } }