english/administrator/components/com_aicontactsafe/models/profiles.php
//function to write data in other tables then the default one of the current sTask
function to write data in other tables then the default one of the current sTask
function to write data in other tables then the default one of the current sTask
function writeOtherTables( $postData = array(), $id = 0 ) {
		$id = (int)$id;
		$name = $postData['name'];
		$meta_description = $postData['meta_description'];
		$meta_keywords = $postData['meta_keywords'];
		$meta_robots = $postData['meta_robots'];
		$thank_you_message = JRequest::getVar('thank_you_message', '', 'post', 'string', JREQUEST_ALLOWHTML);
		if (strlen(trim($thank_you_message)) == 0) {
			$thank_you_message = '&nbsp;';
		}
		$thank_you_message = $this->replace_specialchars($thank_you_message);
		$required_field_notification = JRequest::getVar('required_field_notification', '', 'post', 'string', JREQUEST_ALLOWHTML);
		$required_field_notification = $this->replace_specialchars($required_field_notification);
		$db = &JFactory::getDBO();
		$query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $id . ' and info_key = \'meta_description\'';
		$db->setQuery( $query );
		$added = $db->loadResult();
		if ($added > 0) {
			$query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'meta_description (' . $name . ')\', info_value = \'' . $meta_description . '\' WHERE profile_id = ' . $id . ' and info_key = \'meta_description\'';
		} else {
			$query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $id . ', \'meta_description\', \'meta_description (' . $name . ')\', \'' . $meta_description . '\')';
		}
		$db->setQuery( $query );
		$db->query();
		$query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $id . ' and info_key = \'meta_keywords\'';
		$db->setQuery( $query );
		$added = $db->loadResult();
		if ($added > 0) {
			$query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'meta_keywords (' . $name . ')\', info_value = \'' . $meta_keywords . '\' WHERE profile_id = ' . $id . ' and info_key = \'meta_keywords\'';
		} else {
			$query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $id . ', \'meta_keywords\', \'meta_keywords (' . $name . ')\', \'' . $meta_keywords . '\')';
		}
		$db->setQuery( $query );
		$db->query();
		$query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $id . ' and info_key = \'meta_robots\'';
		$db->setQuery( $query );
		$added = $db->loadResult();
		if ($added > 0) {
			$query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'meta_robots (' . $name . ')\', info_value = \'' . $meta_robots . '\' WHERE profile_id = ' . $id . ' and info_key = \'meta_robots\'';
		} else {
			$query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $id . ', \'meta_robots\', \'meta_robots (' . $name . ')\', \'' . $meta_robots . '\')';
		}
		$db->setQuery( $query );
		$db->query();
		$query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $id . ' and info_key = \'thank_you_message\'';
		$db->setQuery( $query );
		$added = $db->loadResult();
		if ($added > 0) {
			$query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'thank_you_message (' . $name . ')\', info_value = \'' . $thank_you_message . '\' WHERE profile_id = ' . $id . ' and info_key = \'thank_you_message\'';
		} else {
			$query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $id . ', \'thank_you_message\', \'thank_you_message (' . $name . ')\', \'' . $thank_you_message . '\')';
		}
		$db->setQuery( $query );
		$db->query();
		$query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $id . ' and info_key = \'required_field_notification\'';
		$db->setQuery( $query );
		$added = $db->loadResult();
		if ($added > 0) {
			$query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'required_field_notification (' . $name . ')\', info_value = \'' . $required_field_notification . '\' WHERE profile_id = ' . $id . ' and info_key = \'required_field_notification\'';
		} else {
			$query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $id . ', \'required_field_notification\', \'required_field_notification (' . $name . ')\', \'' . $required_field_notification . '\')';
		}
		$db->setQuery( $query );
		$db->query();
		if ($postData['id'] != $id) {
			$postData['display_format'] = 0;
			$postData['plg_contact_info'] = 0;
			$postData['contact_info'] = '';
			$this->writeContactInformation($postData,$id);
			$postData['use_message_css'] = 1;
			$postData['profile_css_code'] = $this->readProfileCssFile();
			$this->writeCSS($postData,$id);
			$postData['use_mail_template'] = 1;
			$postData['mail_template'] = $this->readMailTemplate();
			$this->writeEmail($postData,$id);
		}
		return true;
	}
function writeOtherTables ( $ postData = array ( ) , $ id = 0 ) { $ id = ( int ) $ id ; $ name = $ postData [ 'name' ] ; $ meta_description = $ postData [ 'meta_description' ] ; $ meta_keywords = $ postData [ 'meta_keywords' ] ; $ meta_robots = $ postData [ 'meta_robots' ] ; $ thank_you_message = JRequest :: getVar ( 'thank_you_message' , '' , 'post' , 'string' , JREQUEST_ALLOWHTML ) ; if ( strlen ( trim ( $ thank_you_message ) ) == 0 ) { $ thank_you_message = '&nbsp;' ; } $ thank_you_message = $ this -> replace_specialchars ( $ thank_you_message ) ; $ required_field_notification = JRequest :: getVar ( 'required_field_notification' , '' , 'post' , 'string' , JREQUEST_ALLOWHTML ) ; $ required_field_notification = $ this -> replace_specialchars ( $ required_field_notification ) ; $ db = & JFactory :: getDBO ( ) ; $ query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $ id . ' and info_key = \'meta_description\'' ; $ db -> setQuery ( $ query ) ; $ added = $ db -> loadResult ( ) ; if ( $ added > 0 ) { $ query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'meta_description (' . $ name . ')\', info_value = \'' . $ meta_description . '\' WHERE profile_id = ' . $ id . ' and info_key = \'meta_description\'' ; } else { $ query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $ id . ', \'meta_description\', \'meta_description (' . $ name . ')\', \'' . $ meta_description . '\')' ; } $ db -> setQuery ( $ query ) ; $ db -> query ( ) ; $ query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $ id . ' and info_key = \'meta_keywords\'' ; $ db -> setQuery ( $ query ) ; $ added = $ db -> loadResult ( ) ; if ( $ added > 0 ) { $ query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'meta_keywords (' . $ name . ')\', info_value = \'' . $ meta_keywords . '\' WHERE profile_id = ' . $ id . ' and info_key = \'meta_keywords\'' ; } else { $ query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $ id . ', \'meta_keywords\', \'meta_keywords (' . $ name . ')\', \'' . $ meta_keywords . '\')' ; } $ db -> setQuery ( $ query ) ; $ db -> query ( ) ; $ query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $ id . ' and info_key = \'meta_robots\'' ; $ db -> setQuery ( $ query ) ; $ added = $ db -> loadResult ( ) ; if ( $ added > 0 ) { $ query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'meta_robots (' . $ name . ')\', info_value = \'' . $ meta_robots . '\' WHERE profile_id = ' . $ id . ' and info_key = \'meta_robots\'' ; } else { $ query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $ id . ', \'meta_robots\', \'meta_robots (' . $ name . ')\', \'' . $ meta_robots . '\')' ; } $ db -> setQuery ( $ query ) ; $ db -> query ( ) ; $ query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $ id . ' and info_key = \'thank_you_message\'' ; $ db -> setQuery ( $ query ) ; $ added = $ db -> loadResult ( ) ; if ( $ added > 0 ) { $ query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'thank_you_message (' . $ name . ')\', info_value = \'' . $ thank_you_message . '\' WHERE profile_id = ' . $ id . ' and info_key = \'thank_you_message\'' ; } else { $ query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $ id . ', \'thank_you_message\', \'thank_you_message (' . $ name . ')\', \'' . $ thank_you_message . '\')' ; } $ db -> setQuery ( $ query ) ; $ db -> query ( ) ; $ query = 'SELECT id FROM #__aicontactsafe_contactinformations WHERE profile_id = ' . $ id . ' and info_key = \'required_field_notification\'' ; $ db -> setQuery ( $ query ) ; $ added = $ db -> loadResult ( ) ; if ( $ added > 0 ) { $ query = 'UPDATE `#__aicontactsafe_contactinformations` set info_label = \'required_field_notification (' . $ name . ')\', info_value = \'' . $ required_field_notification . '\' WHERE profile_id = ' . $ id . ' and info_key = \'required_field_notification\'' ; } else { $ query = 'INSERT INTO `#__aicontactsafe_contactinformations` (`id`, `profile_id`, `info_key`, `info_label`, `info_value`) VALUES (null, ' . $ id . ', \'required_field_notification\', \'required_field_notification (' . $ name . ')\', \'' . $ required_field_notification . '\')' ; } $ db -> setQuery ( $ query ) ; $ db -> query ( ) ; if ( $ postData [ 'id' ] != $ id ) { $ postData [ 'display_format' ] = 0 ; $ postData [ 'plg_contact_info' ] = 0 ; $ postData [ 'contact_info' ] = '' ; $ this -> writeContactInformation ( $ postData , $ id ) ; $ postData [ 'use_message_css' ] = 1 ; $ postData [ 'profile_css_code' ] = $ this -> readProfileCssFile ( ) ; $ this -> writeCSS ( $ postData , $ id ) ; $ postData [ 'use_mail_template' ] = 1 ; $ postData [ 'mail_template' ] = $ this -> readMailTemplate ( ) ; $ this -> writeEmail ( $ postData , $ id ) ; } return true ; }
function to write data in other tables then the default one of the current sTask
function to write data in other tables then the default one of the current sTask
// get the information in the form // initialize the database // save meta_description // save meta_keywords // save meta_robots // save thank you message // save required_field_notification // if the profile was just added create the css and email template files  // write contact information // write CSS // write email template