getPath( 'class', 'com_chronocontact' ) ); // the class name must be the same as the file name without the .php at the end class cf_email_verification { //the next 3 fields must be defined for every plugin var $result_TITLE = "Email Verification"; var $result_TOOLTIP = "Let the user verify his email address before the form data go through the emails or the database table!"; var $plugin_name = "cf_email_verification"; // 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; $database =& JFactory::getDBO(); jimport('joomla.html.pane'); $pane =& JPane::getInstance('tabs'); $paramsvalues = new JParameter($row->params); $tables = $database->getTableList(); ?>
startPane("emailverification"); echo $pane->startPanel( 'Email Settings', "email3" ); ?>
:
:
:
:
:
:
:
:
: display( 'extra1', $row->extra1 , '100%', '350', '75', '20', false ) ; ?>
endPanel(); echo $pane->startPanel( "OnSubmit Code", 'onsubmitcode' ); ?>
:
:
:
:
endPanel(); echo $pane->startPanel( "DB Config", 'dbconfig' ); ?> getTableList(); $tables_array = array('' => JHTML::_('select.option', JText::_('--?--'))); foreach ( $tables as $k => $table ) { $tables_array[$table] = JHTML::_('select.option', JText::_($table)); } ?>
: get('vtablename'), '', ''); ?>
:
endPanel(); echo $pane->endPane(); ?>
bind( $post )) { JError::raiseWarning(100, $row->getError()); $mainframe->redirect( "index2.php?option=$option" ); } ///$params = mosGetParam( $_POST, 'params', '' ); $params = JRequest::getVar( 'params', '', 'post', 'array', array(0) ); if (is_array( $params )) { $txt = array(); foreach ( $params as $k=>$v) { $txt[] = "$k=$v"; } $row->params = implode( "\n", $txt ); } if (!$row->store()) { JError::raiseWarning(100, $row->getError()); $mainframe->redirect( "index2.php?option=$option" ); } $mainframe->redirect( "index2.php?option=".$option, "Config Saved" ); } function onload( $option, $row, $params, $html_string ) { global $mainframe; $my = JFactory::getUser(); $database =& JFactory::getDBO(); $formname = JRequest::getVar( 'chronoformname'); $MyForm =& CFChronoForm::getInstance($formname); $MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id); $MyCustomCode =& CFCustomCode::getInstance($MyForm->formrow->id); if(JRequest::getVar('task') == 'beforeshow'){ $query = "SELECT * FROM ".trim($params->get('vtablename'))." WHERE uid='".JRequest::getVar('uid')."' AND ".trim($params->get('vflagfield'))." = 0"; $database->setQuery( $query ); $result = $database->loadObject(); if($result){ $database->setQuery( "UPDATE ".trim($params->get('vtablename'))." SET ".trim($params->get('vflagfield'))." = 1 WHERE uid='".JRequest::getVar('uid')."'"); if (!$database->query()) { JError::raiseWarning(100, $database->getErrorMsg()); //$mainframe->redirect( "index.php?option=$option" ); } if ( !empty($row->extra3) ) { ob_start(); eval( "?>".$row->extra3 ); $extra3 = ob_get_clean(); } //get table column names $tables = array(); $tables[] = trim($params->get('vtablename')); $fieldsdata = $database->getTableFields( $tables ); $table_fields = array_keys($fieldsdata[trim($params->get('vtablename'))]); $postdata = array(); foreach ( $table_fields as $table_field) { $extra3 = str_replace("{".$table_field."}", $result->$table_field, $extra3); $postdata[$table_field] = $result->$table_field; } //send emails $MyFormEmails->sendEmails($MyForm, $MyFormEmails->emails, $postdata); //do other onsubmit routines $MyCustomCode->runCode( 'onsubmitcode' ); /** * Redirect the page if requested */ if ( !$MyForm->formparams('debug') ) { if ( !empty($MyForm->formrow->redirecturl) ) { $mainframe->redirect($MyForm->formrow->redirecturl); } } $html_string = $extra3; }else{ //check if the record is already verified $query = "SELECT * FROM ".trim($params->get('vtablename'))." WHERE uid='".JRequest::getVar('uid')."' AND ".trim($params->get('vflagfield'))." = 1"; $database->setQuery( $query ); $verified = $database->loadObject(); if($verified){ if ( !empty($row->extra5) ) { ob_start(); eval( "?>".$row->extra5 ); $extra5 = ob_get_clean(); $html_string = $extra5; } }else{ if ( !empty($row->extra4) ) { ob_start(); eval( "?>".$row->extra4 ); $extra4 = ob_get_clean(); $html_string = $extra4; } } } } return $html_string ; } function onsubmit( $option, $params , $row ) { global $mainframe; $database =& JFactory::getDBO(); $pluginrow = $row; $posted = JRequest::get( 'post' , JREQUEST_ALLOWRAW ); $formname = JRequest::getVar( 'chronoformname'); $MyForm =& CFChronoForm::getInstance($formname); $MyFormEmails =& CFEMails::getInstance($MyForm->formrow->id); $MyCustomCode =& CFCustomCode::getInstance($MyForm->formrow->id); //save the data $posted[$params->get('vflagfield')] = 0; if ( !empty($MyForm->formrow->autogenerated) ) { eval( "?>".$MyForm->formrow->autogenerated ); } //run the onsubmit before verification code if ( !empty($pluginrow->extra2) ) { eval( "?>".$pluginrow->extra2 ); } //send the verification email if($params->get('subject')){ $subject = $params->get('subject'); }else{ $subject = $posted[$params->get('dsubject')]; } if($params->get('to')){ $recipients = $params->get('to'); }else{ $recipients = $posted[$params->get('dto')]; } if($params->get('fromname')){ $fromname = $params->get('fromname'); }else{ $fromname = $posted[$params->get('dfromname')]; } if($params->get('fromemail')){ $fromemail = $params->get('fromemail'); }else{ $fromemail = $posted[$params->get('dfromemail')]; } $email_body = $pluginrow->extra1; foreach($posted as $key => $value){ $email_body = str_replace("{".$key."}", $value, $email_body); } //global ${'row_'.$params->get('vtablename')}; $vlink = JURI::Base().'index.php?option=com_chronocontact&chronoformname='.$formname.'&task=beforeshow&uid='.$MyForm->tablerow[$params->get('vtablename')]->uid; $vlink = ''.$vlink.''; $email_body = str_replace("{vlink}", $vlink, $email_body); //echo $email_body; JUtility::sendMail($fromemail, $fromname, $recipients, $subject, $email_body, true); //exit the form routine $MyForm->stoprunning = true; return; } } ?>