english/components/com_aicontactsafe/controllers/message.php
// default function to call when a task is not specified
default function to call when a task is not specified
default function to call when a task is not specified
function display( $returnAjaxForm = false ) {
		$model = &$this->getModel( $this->_sTaskModel, '', $this->_parameters );
		$use_ajax = JRequest::getVar( 'use_ajax', 0, 'request', 'int');
		$send_mail = JRequest::getVar( 'send_mail', 0, 'post', 'int');
		jimport('joomla.environment.browser');
		$navigator = JBrowser::getInstance();
		$navigator->setBrowser('mozilla');
		$ban_ip = $model->checkBanIp();
		if ( $ban_ip ) {
			$link = $this->_config_values['redirect_ips'];
			if (strlen(trim($link)) == 0) {
				$link = JURI::base();
			}
			if ($use_ajax) {
				echo '<input type="hidden" id="ajax_return_to" name="ajax_return_to" value="'.$link.'" />'.JText::_('COM_AICONTACTSAFE_PLEASE_WAIT');
			} else {
				$this->setRedirect($link);
			}
		} else {
			if ($send_mail == 1) {
				$isOK = $model->getFormFields();
				if ($isOK) {
					$isOK = $model->SendEmail();
				}
				$new_values = array();
				$new_values['r_id'] = JRequest::getInt( 'r_id', mt_rand() );
				if ($isOK) {
					$link = $model->getReturnLink($new_values, $use_ajax);
					$pf = JRequest::getInt( 'pf' );
					$contactinformations = $model->readContactInformations( $pf, $new_values['r_id'] );
					$msg = array_key_exists('thank_you_message',$contactinformations)?$contactinformations['thank_you_message']:'';
					$msgType = 'message';
				} else {
					$link = $model->getLastLink($new_values, $use_ajax);
					$msg = $this->_app->_session->get( 'errorMsg:' . $this->_sTask );
					$msgType = 'error';
				}
				if (strlen($msg) > 2) {
					$this->setRedirect($link, $msg, $msgType);
                } else {
					$this->setRedirect($link);
                }
			} elseif ($send_mail == 2) {
				$link = $model->getReturnLink();
				$this->setRedirect($link);
			} else {
				$dt = JRequest::getVar('dt', 0, 'post', 'int');
				if ( $dt ) {
					$model->getFormFields();
				}
				$view = &$this->getView( $this->_sTaskView, 'html', '', $this->_parameters );
				$view->setModel( $model, true );
				$view->setLayout( $this->_sTaskLayout );
				$view->viewDefault( $returnAjaxForm );
			}
		}
		$this->recordLastTask();
	}
function display ( $ returnAjaxForm = false ) { $ model = & $ this -> getModel ( $ this -> _sTaskModel , '' , $ this -> _parameters ) ; $ use_ajax = JRequest :: getVar ( 'use_ajax' , 0 , 'request' , 'int' ) ; $ send_mail = JRequest :: getVar ( 'send_mail' , 0 , 'post' , 'int' ) ; jimport ( 'joomla.environment.browser' ) ; $ navigator = JBrowser :: getInstance ( ) ; $ navigator -> setBrowser ( 'mozilla' ) ; $ ban_ip = $ model -> checkBanIp ( ) ; if ( $ ban_ip ) { $ link = $ this -> _config_values [ 'redirect_ips' ] ; if ( strlen ( trim ( $ link ) ) == 0 ) { $ link = JURI :: base ( ) ; } if ( $ use_ajax ) { echo '<input type="hidden" id="ajax_return_to" name="ajax_return_to" value="' . $ link . '" />' . JText :: _ ( 'COM_AICONTACTSAFE_PLEASE_WAIT' ) ; } else { $ this -> setRedirect ( $ link ) ; } } else { if ( $ send_mail == 1 ) { $ isOK = $ model -> getFormFields ( ) ; if ( $ isOK ) { $ isOK = $ model -> SendEmail ( ) ; } $ new_values = array ( ) ; $ new_values [ 'r_id' ] = JRequest :: getInt ( 'r_id' , mt_rand ( ) ) ; if ( $ isOK ) { $ link = $ model -> getReturnLink ( $ new_values , $ use_ajax ) ; $ pf = JRequest :: getInt ( 'pf' ) ; $ contactinformations = $ model -> readContactInformations ( $ pf , $ new_values [ 'r_id' ] ) ; $ msg = array_key_exists ( 'thank_you_message' , $ contactinformations ) ? $ contactinformations [ 'thank_you_message' ] : '' ; $ msgType = 'message' ; } else { $ link = $ model -> getLastLink ( $ new_values , $ use_ajax ) ; $ msg = $ this -> _app -> _session -> get ( 'errorMsg:' . $ this -> _sTask ) ; $ msgType = 'error' ; } if ( strlen ( $ msg ) > 2 ) { $ this -> setRedirect ( $ link , $ msg , $ msgType ) ; } else { $ this -> setRedirect ( $ link ) ; } } elseif ( $ send_mail == 2 ) { $ link = $ model -> getReturnLink ( ) ; $ this -> setRedirect ( $ link ) ; } else { $ dt = JRequest :: getVar ( 'dt' , 0 , 'post' , 'int' ) ; if ( $ dt ) { $ model -> getFormFields ( ) ; } $ view = & $ this -> getView ( $ this -> _sTaskView , 'html' , '' , $ this -> _parameters ) ; $ view -> setModel ( $ model , true ) ; $ view -> setLayout ( $ this -> _sTaskLayout ) ; $ view -> viewDefault ( $ returnAjaxForm ) ; } } $ this -> recordLastTask ( ) ; }
default function to call when a task is not specified
default function to call when a task is not specified
// get the model for this task and sTask // check if the form is using ajax // force the browser to mozilla so the redirect will be done with php headers not with javascript ( which is now done in Joomla 1.6 ) // check if the IP used to access this page is banned // the send button was pressed // read the fields sent in the form // if the fields are read without any error, the message is sent // if back button was pressed // the form is displayed for the first time // read the fields sent when the contact form was called // generate the view