getPath( 'class', 'com_chronocontact' ) );
// the class name must be the same as the file name without the .php at the end
class cf_confirmation_page
{
//the next 3 fields must be defined for every plugin
var $result_TITLE = "Confirmation Page";
var $result_TOOLTIP = "This plugin will help you to create a confirmation page to show the user the data he/she provided before its submitted";
var $plugin_name = "cf_confirmation_page"; // must be the same as the class name
var $event = "ONLOADONSUBMIT"; // must be defined and in Uppercase, should be ONSUBMIT or ONLOAD or ONLOADONSUBMIT, the last one is for v3.1 RC3 and up only
var $plugin_keys ='';
// the next function must exist and will have the backend config code
function show_conf($row, $id, $form_id, $option)
{
global $mainframe;
require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_chronocontact'.DS.'helpers'.DS.'plugin.php');
$helper = new ChronoContactHelperPlugin();
// identify and initialise the parameters used in this plugin
$params_array = array(
'editor' => '1',
'buttons' => '0');
$params = $helper->loadParams($row, $params_array);
if ( $params->get('editor') == 'No' ) {
$params->set('editor', '0');
} elseif ( $params->get('editor') == 'Yes' ) {
$params->set('editor', '1');
}
if ( $params->get('buttons') == 'No' ) {
$params->set('buttons', '0');
} elseif ($params->get('buttons') == 'Yes' ) {
$params->set('buttons', '1');
}
//echo '
$params: '.print_r($params, true).'
';
$params = new JParameter($row->params);
?>
save_conf($option);
}
function onload( $option, $row, $params, $html_string )
{
global $mainframe;
$my = JFactory::getUser();
$db =& JFactory::getDBO();
$session =& JFactory::getSession();
//get chrono instances
$formname = JRequest::getVar( 'chronoformname');
$MyForm =& CFChronoForm::getInstance($formname);
$MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id);
$MyCustomCode =& CFCustomCode::getInstance($MyForm->formrow->id);
$MyPlugins =& CFPlugins::getInstance($MyForm->formrow->id);
if ( JRequest::getVar('task') != 'beforeshow' ) {
$session->set("chrono_next_step", '', md5('chrono'));
}
$chrono_next_step = $session->get('chrono_next_step', '', md5('chrono'));
if ( $chrono_next_step == 'confirm' ) {
if ( (!JRequest::checkToken()) && $MyForm->formparams('checkToken', 1) ) {
echo "You are not allowed to access this URL";
return;
}
$html_string = '';
$posted = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
if ( JRequest::getVar('confirm') == trim($params->get('submit_button_value', 'Submit')) ) {
$debug = $MyForm->formparams('debug');
//handle arrays
$MyForm->handleArrays($MyForm->formrow->name);
/**
* If there are no errors and e-mail is required then build and send it.
*/
if ( ($MyForm->formrow->emailresults != 0) && !$MyForm->error_found && !$MyForm->stoprunning ) {
//run before submit code
if ( !$MyForm->haltFunction["onsubmitcodeb4"] ) {
$MyCustomCode->runCode( 'onsubmitcodeb4' );
if ( $MyForm->showFormErrors($MyForm->formrow->name) ) {
$MyForm->showForm($MyForm->formrow->name, $posted);
return;
}
}
if ( !$MyForm->haltFunction["autogenerated_before_email"] ) {
$MyCustomCode->runCode( 'autogenerated', 'before_email' );
}
//send emails
if ( !$MyForm->haltFunction["emails"] ) {
$emails_result = $MyFormEmails->sendEmails($MyForm, $MyFormEmails->emails);
}
}
if ( !$MyForm->error_found && !$MyForm->stoprunning ) {
/*************** check to see if order was specified, if not then use the default old one ************************/
if ( !$MyForm->formparams('plugins_order')
&& !$MyForm->formparams('onsubmitcode_order')
&& !$MyForm->formparams('autogenerated_order') ) {
$MyForm->setFormParam('autogenerated_order', 3);
$MyForm->setFormParam('onsubmitcode_order', 2);
$MyForm->setFormParam('plugins_order', 1);
}
for ( $ixx = 1 ; $ixx <= 3; $ixx++ ) {
if ( $MyForm->formparams('plugins_order') == $ixx ) {
if ( !$MyForm->haltFunction["plugins_after_email"] ) {
$MyPlugins->runPlugin('after_email');
//show errors if any
if ( $MyForm->showFormErrors($MyForm->formrow->name) ) {
$MyForm->showForm($MyForm->formrow->name, $posted);
return;
}
}
}
/**
* Run the On-submit 'post e-mail' code if there is any
*/
if ( $MyForm->formparams('onsubmitcode_order') == $ixx ) {
if ( !$MyForm->haltFunction["onsubmitcode"] ) {
$MyCustomCode->runCode( 'onsubmitcode' );
if ( $MyForm->showFormErrors($MyForm->formrow->name) ) {
$MyForm->showForm($MyForm->formrow->name, $posted);
return;
}
}
}
/**
* Run the SQL query if there is one
*/
if ( $MyForm->formparams('autogenerated_order') == $ixx ) {
if ( !$MyForm->haltFunction["autogenerated_after_email"] ) {
$MyCustomCode->runCode( 'autogenerated', 'after_email' );
}
}
}
//Mark submission as complete!
$MyForm->submission_complete = true;
$MyForm->addDebugMsg('Debug End');
/**
* Redirect the page if requested
*/
if ( !empty($MyForm->formrow->redirecturl) ) {
if ( !$debug ) {
$mainframe->redirect($MyForm->formrow->redirecturl);
} else {
$MyForm->addDebugMsg("");
}
}
}
if ( !empty($MyForm->formdebug) && ($MyForm->formparams('debug') == '1') ) {
include_once(JPATH_COMPONENT.DS.'libraries'.DS.'includes'.DS.'Debug.php');
}
$html_string = '';
} else {
$session->set("chrono_next_step", '', md5('chrono'));
$MyForm->showForm($MyForm->formrow->name, $posted);
$MyForm->stoploading = true;
return;
$html_string = '';
}
}
return $html_string ;
}
function onsubmit( $option, $params , $row )
{
global $mainframe;
$db =& JFactory::getDBO();
$pluginrow = $row;
$formname = JRequest::getVar( 'chronoformname');
$MyForm =& CFChronoForm::getInstance($formname);
$posted = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
$session =& JFactory::getSession();
$session->set("chrono_next_step", 'confirm', md5('chrono'));
//show the form
if ( !empty($MyForm->formrow->submiturl) ) {
$actionurl = $MyForm->formrow->submiturl;
} else {
$actionurl = JURI::Base().'index.php?option=com_chronocontact&task=beforeshow&chronoformname='.$MyForm->formrow->name;
if ( JRequest::getInt('Itemid') ) {
$actionurl = $actionurl.'&Itemid='.JRequest::getInt('Itemid');
}
}
$multipart = "";
if ( $MyForm->formparams('uploads') == 'Yes' ) {
$multipart = ' enctype="multipart/form-data"';
}
echo "
stoprunning = true;
return;
}
}
?>