english/administrator/components/com_messages/models/config.php
/**
	 * Method to save the form data.
	 *
	 * @param	array	The form data.
	 * @return	boolean	True on success.
	 */
Method to save the form data.
@param       array   The form data.
@return      boolean True on success.
Method to save the form data . @param array The form data . @return boolean True on success .
public function save($data)
	{
		$db = $this->getDbo();
		if ($userId = (int) $this->getState('user.id')) {
			$db->setQuery(
				'DELETE FROM #__messages_cfg'.
				' WHERE user_id = '. $userId
			);
			$db->query();
			if ($error = $db->getErrorMsg()) {
				$this->setError($error);
				return false;
			}
			$tuples = array();
			foreach ($data as $k => $v) {
				$tuples[] =  '('.$userId.', '.$db->Quote($k).', '.$db->Quote($v).')';
			}
			if ($tuples) {
				$db->setQuery(
					'INSERT INTO #__messages_cfg'.
					' (user_id, cfg_name, cfg_value)'.
					' VALUES '.implode(',', $tuples)
				);
				$db->query();
				if ($error = $db->getErrorMsg()) {
					$this->setError($error);
					return false;
				}
			}
			return true;
		} else {
			$this->setError('COM_MESSAGES_ERR_INVALID_USER');
			return false;
		}
	}
public function save ( $ data ) { $ db = $ this -> getDbo ( ) ; if ( $ userId = ( int ) $ this -> getState ( 'user.id' ) ) { $ db -> setQuery ( 'DELETE FROM #__messages_cfg' . ' WHERE user_id = ' . $ userId ) ; $ db -> query ( ) ; if ( $ error = $ db -> getErrorMsg ( ) ) { $ this -> setError ( $ error ) ; return false ; } $ tuples = array ( ) ; foreach ( $ data as $ k => $ v ) { $ tuples [ ] = '(' . $ userId . ', ' . $ db -> Quote ( $ k ) . ', ' . $ db -> Quote ( $ v ) . ')' ; } if ( $ tuples ) { $ db -> setQuery ( 'INSERT INTO #__messages_cfg' . ' (user_id, cfg_name, cfg_value)' . ' VALUES ' . implode ( ',' , $ tuples ) ) ; $ db -> query ( ) ; if ( $ error = $ db -> getErrorMsg ( ) ) { $ this -> setError ( $ error ) ; return false ; } } return true ; } else { $ this -> setError ( 'COM_MESSAGES_ERR_INVALID_USER' ) ; return false ; } }
Method to save the form data.
Method to save the form data .