english/administrator/components/com_aicontactsafe/controller.php
// function to save all changes and keep the window open for more changes
function to save all changes and keep the window open for more changes
function to save all changes and keep the window open for more changes
function apply() {
		$model = &$this->getModel( $this->_sTaskModel, '', $this->_parameters );
		$isOK = $model->getFormFields();
		if ($isOK) {
			$isOK = $model->writeData();
		}
		$last_task = $this->_app->_session->get( 'last_task' );
		if ($last_task['task'] == 'add') {
			$last_id = $this->_app->_session->get( 'idSaved:' . $this->_sTask );
		} else {
			$last_id = JRequest::getVar( 'id', 0, 'post', 'int');
		}
		$new_values = array();
		$new_values['task'] = 'edit';
		$new_values['id'] = $last_id;
		$link = $model->getLastLink($new_values);
		if ($isOK) {
			$msg = $this->getConfirmationMessage();
			$msgType = 'message';
		} else {
			$msg = $this->_app->_session->get( 'errorMsg:' . $this->_sTask );
			$msgType = 'error';
		}
		$this->setRedirect($link, $msg, $msgType);
	}
function apply ( ) { $ model = & $ this -> getModel ( $ this -> _sTaskModel , '' , $ this -> _parameters ) ; $ isOK = $ model -> getFormFields ( ) ; if ( $ isOK ) { $ isOK = $ model -> writeData ( ) ; } $ last_task = $ this -> _app -> _session -> get ( 'last_task' ) ; if ( $ last_task [ 'task' ] == 'add' ) { $ last_id = $ this -> _app -> _session -> get ( 'idSaved:' . $ this -> _sTask ) ; } else { $ last_id = JRequest :: getVar ( 'id' , 0 , 'post' , 'int' ) ; } $ new_values = array ( ) ; $ new_values [ 'task' ] = 'edit' ; $ new_values [ 'id' ] = $ last_id ; $ link = $ model -> getLastLink ( $ new_values ) ; if ( $ isOK ) { $ msg = $ this -> getConfirmationMessage ( ) ; $ msgType = 'message' ; } else { $ msg = $ this -> _app -> _session -> get ( 'errorMsg:' . $ this -> _sTask ) ; $ msgType = 'error' ; } $ this -> setRedirect ( $ link , $ msg , $ msgType ) ; }
function to save all changes and keep the window open for more changes
function to save all changes and keep the window open for more changes
// read the last task values // if last task is 'add' get the last id saved, else get the id from the post variables // set the new values of the link // get the link with the new values // redirect to the new link