english/components/com_aicontactsafe/models/message.php
// function to read the fields to display into the contact form
function to read the fields to display into the contact form
function to read the fields to display into the contact form
function readFields( $profile = null ) {
		if(!$this->fields) {
			$this->fields = array();
			$db = &JFactory::getDBO();
			if ( $profile->active_fields == 0 ) {
				$query = 'SELECT * FROM #__aicontactsafe_fields WHERE published = 1 ORDER by ordering';
			} else {
				$query = 'SELECT * FROM #__aicontactsafe_fields WHERE published = 1 and id IN ( ' . $profile->active_fields . ' ) ORDER by ordering';
			}
			$db->setQuery( $query );
			$records = $db->loadObjectList();
			$unsorted_fields = array();
			foreach($records as $record) {
				$unsorted_fields[$record->id] = $record;
			}
			$fields_order = explode(',',$profile->fields_order);
			foreach($fields_order as $field_id) {
				if (array_key_exists($field_id, $unsorted_fields)) {
					$this->fields[$unsorted_fields[$field_id]->name] = $unsorted_fields[$field_id];
					unset($unsorted_fields[$field_id]);
				}
			}
			foreach($unsorted_fields as $field) {
				$this->fields[$field->name] = $field;
			}
		}
		return $this->fields;
	}
function readFields ( $ profile = null ) { if ( ! $ this -> fields ) { $ this -> fields = array ( ) ; $ db = & JFactory :: getDBO ( ) ; if ( $ profile -> active_fields == 0 ) { $ query = 'SELECT * FROM #__aicontactsafe_fields WHERE published = 1 ORDER by ordering' ; } else { $ query = 'SELECT * FROM #__aicontactsafe_fields WHERE published = 1 and id IN ( ' . $ profile -> active_fields . ' ) ORDER by ordering' ; } $ db -> setQuery ( $ query ) ; $ records = $ db -> loadObjectList ( ) ; $ unsorted_fields = array ( ) ; foreach ( $ records as $ record ) { $ unsorted_fields [ $ record -> id ] = $ record ; } $ fields_order = explode ( ',' , $ profile -> fields_order ) ; foreach ( $ fields_order as $ field_id ) { if ( array_key_exists ( $ field_id , $ unsorted_fields ) ) { $ this -> fields [ $ unsorted_fields [ $ field_id ] -> name ] = $ unsorted_fields [ $ field_id ] ; unset ( $ unsorted_fields [ $ field_id ] ) ; } } foreach ( $ unsorted_fields as $ field ) { $ this -> fields [ $ field -> name ] = $ field ; } } return $ this -> fields ; }
function to read the fields to display into the contact form
function to read the fields to display into the contact form
// initialize the database // get the fields to display // generate the response array // sort the response array