english/administrator/components/com_aicontactsafe/models/fields.php
// function to check/add/modify different fields before writing them to the database
function to check/add/modify different fields before writing them to the database
function to check / add / modify different fields before writing them to the database
function checkBeforeWrite($postData) {
		if (strlen(trim($postData['name'])) == 0) {
			$this->_app->_session->set( 'isOK:' . $this->_sTask, false );
			$this->_app->_session->set( 'errorMsg:' . $this->_sTask, JText::_('COM_AICONTACTSAFE_PLEASE_ENTER_THE_NAME_OF_THE_FIELD') );
		} else {
			$postData['name'] = $this->onlyLettersAndNumbers($this->revert_specialchars(str_replace(' ','_',$postData['name'])));
			if ( substr($postData['name'],0,5) != 'aics_' ) {
				$postData['name'] = 'aics_' . $postData['name'];
			}
			if ( $this->nameUsed(trim($postData['name']), $postData['id']) ) {
				$this->_app->_session->set( 'isOK:' . $this->_sTask, false );
				$this->_app->_session->set( 'errorMsg:' . $this->_sTask, JText::_('COM_AICONTACTSAFE_THIS_NAME_WAS_USED_ON_ANOTHER_FIELD_PLEASE_USE_A_DIFFERENT_ONE') );
			} else {
				$postData = parent::checkBeforeWrite($postData);
			}
		}
		if (array_key_exists('field_values',$postData) && substr(trim($postData['field_values']),-1,1) == ';') {
			$postData['field_values'] = substr(trim($postData['field_values']),0,-1);
		}
		$postData['field_label'] = JRequest::getVar('field_label', '', 'post', 'string', JREQUEST_ALLOWHTML);
		$postData['field_label'] = $this->replace_specialchars($postData['field_label']);
		$postData['label_parameters'] = $this->replace_specialchars($postData['label_parameters']);
		$postData['field_label_message'] = JRequest::getVar('field_label_message', '', 'post', 'string', JREQUEST_ALLOWHTML);
		$postData['field_label_message'] = $this->replace_specialchars($postData['field_label_message']);
		$postData['label_message_parameters'] = $this->replace_specialchars($postData['label_message_parameters']);
		$postData['field_parameters'] = $this->replace_specialchars($postData['field_parameters']);
		$postData['field_sufix'] = $this->replace_specialchars($postData['field_sufix']);
		$postData['field_prefix'] = $this->replace_specialchars($postData['field_prefix']);
		$postData['label_after_field'] = (array_key_exists('label_after_field',$postData) && $postData['label_after_field'])?1:0;
		$postData['send_message'] = (array_key_exists('send_message',$postData) && $postData['send_message'])?1:0;
		$postData['field_required'] = (array_key_exists('field_required',$postData) && $postData['field_required'])?1:0;
		$postData['field_in_message'] = (array_key_exists('field_in_message',$postData) && $postData['field_in_message'])?1:0;
		$postData['published'] = (array_key_exists('published',$postData) && $postData['published'])?1:0;
		return $postData;
	}
function checkBeforeWrite ( $ postData ) { if ( strlen ( trim ( $ postData [ 'name' ] ) ) == 0 ) { $ this -> _app -> _session -> set ( 'isOK:' . $ this -> _sTask , false ) ; $ this -> _app -> _session -> set ( 'errorMsg:' . $ this -> _sTask , JText :: _ ( 'COM_AICONTACTSAFE_PLEASE_ENTER_THE_NAME_OF_THE_FIELD' ) ) ; } else { $ postData [ 'name' ] = $ this -> onlyLettersAndNumbers ( $ this -> revert_specialchars ( str_replace ( ' ' , '_' , $ postData [ 'name' ] ) ) ) ; if ( substr ( $ postData [ 'name' ] , 0 , 5 ) != 'aics_' ) { $ postData [ 'name' ] = 'aics_' . $ postData [ 'name' ] ; } if ( $ this -> nameUsed ( trim ( $ postData [ 'name' ] ) , $ postData [ 'id' ] ) ) { $ this -> _app -> _session -> set ( 'isOK:' . $ this -> _sTask , false ) ; $ this -> _app -> _session -> set ( 'errorMsg:' . $ this -> _sTask , JText :: _ ( 'COM_AICONTACTSAFE_THIS_NAME_WAS_USED_ON_ANOTHER_FIELD_PLEASE_USE_A_DIFFERENT_ONE' ) ) ; } else { $ postData = parent :: checkBeforeWrite ( $ postData ) ; } } if ( array_key_exists ( 'field_values' , $ postData ) && substr ( trim ( $ postData [ 'field_values' ] ) , - 1 , 1 ) == ';' ) { $ postData [ 'field_values' ] = substr ( trim ( $ postData [ 'field_values' ] ) , 0 , - 1 ) ; } $ postData [ 'field_label' ] = JRequest :: getVar ( 'field_label' , '' , 'post' , 'string' , JREQUEST_ALLOWHTML ) ; $ postData [ 'field_label' ] = $ this -> replace_specialchars ( $ postData [ 'field_label' ] ) ; $ postData [ 'label_parameters' ] = $ this -> replace_specialchars ( $ postData [ 'label_parameters' ] ) ; $ postData [ 'field_label_message' ] = JRequest :: getVar ( 'field_label_message' , '' , 'post' , 'string' , JREQUEST_ALLOWHTML ) ; $ postData [ 'field_label_message' ] = $ this -> replace_specialchars ( $ postData [ 'field_label_message' ] ) ; $ postData [ 'label_message_parameters' ] = $ this -> replace_specialchars ( $ postData [ 'label_message_parameters' ] ) ; $ postData [ 'field_parameters' ] = $ this -> replace_specialchars ( $ postData [ 'field_parameters' ] ) ; $ postData [ 'field_sufix' ] = $ this -> replace_specialchars ( $ postData [ 'field_sufix' ] ) ; $ postData [ 'field_prefix' ] = $ this -> replace_specialchars ( $ postData [ 'field_prefix' ] ) ; $ postData [ 'label_after_field' ] = ( array_key_exists ( 'label_after_field' , $ postData ) && $ postData [ 'label_after_field' ] ) ? 1 : 0 ; $ postData [ 'send_message' ] = ( array_key_exists ( 'send_message' , $ postData ) && $ postData [ 'send_message' ] ) ? 1 : 0 ; $ postData [ 'field_required' ] = ( array_key_exists ( 'field_required' , $ postData ) && $ postData [ 'field_required' ] ) ? 1 : 0 ; $ postData [ 'field_in_message' ] = ( array_key_exists ( 'field_in_message' , $ postData ) && $ postData [ 'field_in_message' ] ) ? 1 : 0 ; $ postData [ 'published' ] = ( array_key_exists ( 'published' , $ postData ) && $ postData [ 'published' ] ) ? 1 : 0 ; return $ postData ; }
function to check/add/modify different fields before writing them to the database
function to check / add / modify different fields before writing them to the database
// check if a name was entered