Location: PHPKode > projects > ChiCoMaS - Chilek CMS > chicomas/objects/obj_dataaccess.php
<?
/*******************************************************************************
* Begin of DataAccess Object Page
********************************************************************************/

class CDataAccess {
	
	/**********************************************************************************
		GetRow function is used for TempDB
	**********************************************************************************/
	function GetRow($sql) {
		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$row = $db->get_row();
			$db->db_disconnect();
		}
		return $row;
	}

	/**********************************************************************************
		GetRows function is used for TempDB
	**********************************************************************************/
	function GetRows($sql) {
		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_tempdbarray = new CTempDBArray();
			while ($row = $db->get_row()) {
				$o_tempdbarray->add($row);
			}
			$db->db_disconnect();
		}
		return $o_tempdbarray;
	}

	/**********************************************************************************
		ExecQuery function is used for TempDB
	**********************************************************************************/
	function ExecQuery($sql) {

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else return false;
		
		return true;	
	}

	/**********************************************************************************
		getRecordCount function is used for TempDB
	**********************************************************************************/
	function AddRecord($sql) {

		$last_record = 0;
		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$last_record = $db->getLastRecord();
			$db->db_disconnect();				
		}
		return $last_record;
	}

	/**********************************************************************************
		getRecordCount function is used for TempDB
	**********************************************************************************/
	function getRecordCount($sql) {
		$db = new db();
		$db->db_connect();
		if ($db->is_connected())	{
			$db->db_query($sql);
			if ($row = $db->get_row()) {
				$db->db_disconnect();
				return $row['count'];
			}
						
		}
		return false;
	}

	/**********************************************************************************
		SearchResults function is used for Searching Operation
	**********************************************************************************/
	function SearchResults($identifier, $table, $columns, $mysearchterms, $where_data_sql) {
		$mysearch = new MysqlSearch;

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$mysearch->setidentifier($identifier);
			$mysearch->settable($table);
			$mysearch->setsearchcolumns($columns);
			$mysearch->setwhere($where_data_sql);
			$search_results = $mysearch->find($mysearchterms);
			return $search_results;
		}
		else
			return false;
	}

	/*******************************************************************************
	* Languages
	********************************************************************************
	* function GetLanguages()						: CLanguageArray
	*
	********************************************************************************/
	function GetLanguages($active) {

		$o_language = new CLanguage();

		$sql  = "SELECT * FROM languages ";
		if ($active)
			$sql .= "WHERE active='1' ";
		$sql .= "ORDER BY ".$o_language->order_by;
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_languagearray = new CLanguageArray();
			while ($row = $db->get_row()) {
				$o_language = new CLanguage($row);
				$o_languagearray->add($o_language);
			}
			$db->db_disconnect();
		}
		return $o_languagearray;
	}

	/*********************************************************/
	function GetLanguage($lang) {

		$sql  = "SELECT * FROM languages ";
		$sql .= "WHERE lang='".strtolower($lang)."' ";
		$sql .= "AND active='1'";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_language = new CLanguage($row);
			}
			$db->db_disconnect();
		}
			return $o_language;
	}

	/*********************************************************/
	function FindLanguage($languageid) {

		$sql  = "SELECT * FROM languages ";
		$sql .= "WHERE language_id='".$languageid."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_language = new CLanguage($row);
			}
			$db->db_disconnect();
		}
			return $o_language;
	}

	/*********************************************************/
	function UpdateLanguage($lang, $active) {
		$sql = "UPDATE languages ";
		$sql .= "SET ";
		$sql .= "active = ".$active." ";
		$sql .= "WHERE lang='".$lang."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else return false;
		
		return true;	
	}

	/*********************************************************/
	function ResetDefaultLanguage() {

		$sql = "UPDATE languages ";
		$sql .= "SET ";
		$sql .= "default_lang = 0 ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else return false;
		
		return true;	
	}

	/*********************************************************/
	function SetDefaultLanguage($lang) {

		$sql = "UPDATE languages ";
		$sql .= "SET ";
		$sql .= "default_lang = 1, ";
		$sql .= "active = 1 ";
		$sql .= "WHERE lang='".$lang."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else return false;
		
		return true;	
	}


	/*******************************************************************************
	* Users
	********************************************************************************
	* function GetUsers()						: CUserArray
	* function FindUser()						: CUser
	* function InsertUser()					: Last Record
	*
	********************************************************************************/
	function GetUsers() {

		$o_user = new CUser();

		$sql = "SELECT * FROM users ORDER BY ".$o_user->order_by;
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_userarray = new CUserArray();
			while ($row = $db->get_row()) {
				$o_user = new CUser($row);
				$o_userarray->add($o_user);
			}
			$db->db_disconnect();
		}
		return $o_userarray;
	}

	/*********************************************************/
	function FindUser($CUser) {

		$sql  = "SELECT * FROM users ";
		if (valid_email($CUser->username))
			$sql .= "WHERE email='".$CUser->username."' ";
		else
			$sql .= "WHERE username='".$CUser->username."' ";
		$sql .= "AND password='".$CUser->password."' ";
		$sql .= "AND active='1'";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_user = new CUser($row);
			}
			$db->db_disconnect();
		}
			return $o_user;
	}

	/*********************************************************/
	function FindUsername($username) {

		$sql  = "SELECT * FROM users ";
		$sql .= "WHERE username='".$username."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_user = new CUser($row);
			}
			$db->db_disconnect();
		}
			return $o_user;
	}

	/*********************************************************/
	function FindUserbyID($userid) {

		$sql  = "SELECT * FROM users ";
		$sql .= "WHERE user_id='".$userid."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_user = new CUser($row);
			}
			$db->db_disconnect();
		}
			return $o_user;
	}

	/*********************************************************/
	function InsertUser($CUser) {

		$sql = "INSERT INTO users ";
		$sql .= "( ";
			$sql .= "active, ";
			$sql .= "name_surname, ";
			$sql .= "username, ";
			$sql .= "password, ";
			$sql .= "email, ";
			$sql .= "permission, ";
			$sql .= "reg_date, ";
			$sql .= "last_login ";
		$sql .= ") ";
		$sql .= "VALUES";
		$sql .= "( ";
			$sql .= "'".$CUser->active."', ";
			$sql .= "'".$CUser->name_surname."', ";
			$sql .= "'".$CUser->username."', ";
			$sql .= "'".$CUser->password."', ";
			$sql .= "'".$CUser->email."', ";
			$sql .= "'".$CUser->permission."', ";
			$sql .= "'".$CUser->reg_date."', ";
			$sql .= "'".$CUser->last_login."' ";
		$sql .= ") ";
		//echo "SQL:".$sql."<br>";

		$last_record = 0;
		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$last_record = $db->getLastRecord();
			$db->db_disconnect();				
		}
		return $last_record;
	}

	/*********************************************************/
	function DeleteUser($userid) {

		$sql = "DELETE FROM users ";
		$sql .= "WHERE user_id='".$userid."'";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()) {
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else 
			return false;
		
		return true;
	}

	/*********************************************************/
	function UpdateUser($CUser) {

		$sql = "UPDATE users ";
		$sql .= "SET ";
		$sql .= "active = '".$CUser->active."', ";
		$sql .= "name_surname = '".$CUser->name_surname."', ";
		$sql .= "username = '".$CUser->username."', ";
		$sql .= "password = '".$CUser->password."', ";
		$sql .= "email = '".$CUser->email."', ";
		$sql .= "permission = '".$CUser->permission."', ";
		$sql .= "last_login = '".$CUser->last_login."' ";
		$sql .= "WHERE user_id='".$CUser->user_id."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else return false;
		
		return true;		
	}

	/*******************************************************************************
	* Pages
	********************************************************************************
	* function GetPage()						: CPage
	* function GetParentPages()				: CPageArray
	* function GetChildPages()				: CPageArray
	* function InsertPage()					: Last_Record
	* function UpdatePage()					: Boolean
	* function DeletePage()					: Boolean
	* function DeletePageByRef()			: Boolean
	********************************************************************************/
	function GetPage($page_id) {

		$sql  = "SELECT * FROM pages ";
		$sql .= "WHERE page_id='".$page_id."' ";
		//$sql .= "AND active='1'";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_page = new CPage($row);
			}
			$db->db_disconnect();
		}
			return $o_page;
	}


	/*********************************************************/
	function GetParentPages($active) {

		$o_page = new CPage();

		$sql  = "SELECT * FROM pages ";
		$sql .= "WHERE ref_id='0' ";
		if ($active==1)
			$sql .= "AND active='1' ";
		if ($active==0)
			$sql .= "AND active='0' ";
		$sql .= "ORDER BY order_id";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_pagearray = new CPageArray();
			while ($row = $db->get_row()) {
				$o_page = new CPage($row);
				$o_pagearray->add($o_page);
			}
			$db->db_disconnect();
		}
		return $o_pagearray;
	}

	/*********************************************************/
	function GetChildPages($parent_page_id, $active) {

		$o_page = new CPage();

		$sql  = "SELECT * FROM pages ";
		$sql .= "WHERE ref_id='".$parent_page_id."' ";
		if ($active==1)
			$sql .= "AND active='1' ";
		if ($active==0)
			$sql .= "AND active='0' ";
		$sql .= "ORDER BY order_id";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_pagearray = new CPageArray();
			while ($row = $db->get_row()) {
				$o_page = new CPage($row);
				$o_pagearray->add($o_page);
			}
			$db->db_disconnect();
		}
		return $o_pagearray;
	}

	/*********************************************************/
	function GetChildPagesCount($active) {

		$o_page = new CPage();

		$sql  = "SELECT * FROM pages ";
		$sql .= "WHERE ref_id>'0' ";
		if ($active==1)
			$sql .= "AND active='1' ";
		if ($active==0)
			$sql .= "AND active='0' ";
		$sql .= "ORDER BY order_id";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_pagearray = new CPageArray();
			while ($row = $db->get_row()) {
				$o_page = new CPage($row);
				$o_pagearray->add($o_page);
			}
			$db->db_disconnect();
		}
		return $o_pagearray;
	}

	/*********************************************************/
	function GetParentMenuItems() {

		$o_page = new CPage();

		$sql  = "SELECT * FROM pages ";
		$sql .= "WHERE ref_id='0' ";
		$sql .= "AND menu_item='1' ";
		$sql .= "AND active='1' ";
		$sql .= "ORDER BY order_id";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_pagearray = new CPageArray();
			while ($row = $db->get_row()) {
				$o_page = new CPage($row);
				$o_pagearray->add($o_page);
			}
			$db->db_disconnect();
		}
		return $o_pagearray;
	}

	/*********************************************************/
	function GetChildMenuItems($parent_page_id) {

		$o_page = new CPage();

		$sql  = "SELECT * FROM pages ";
		$sql .= "WHERE ref_id='".$parent_page_id."' ";
		$sql .= "AND menu_item='1' ";
		$sql .= "AND active='1' ";
		$sql .= "ORDER BY order_id";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_pagearray = new CPageArray();
			while ($row = $db->get_row()) {
				$o_page = new CPage($row);
				$o_pagearray->add($o_page);
			}
			$db->db_disconnect();
		}
		return $o_pagearray;
	}

	/*********************************************************/
	function GetTopMenuItems() {

		$o_page = new CPage();

		$sql  = "SELECT * FROM pages ";
		$sql .= "WHERE ref_id='0' ";
		$sql .= "AND topmenu_item='1' ";
		$sql .= "AND active='1' ";
		$sql .= "ORDER BY order_id ";
		$sql .= "LIMIT 0,6";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_pagearray = new CPageArray();
			while ($row = $db->get_row()) {
				$o_page = new CPage($row);
				$o_pagearray->add($o_page);
			}
			$db->db_disconnect();
		}
		return $o_pagearray;
	}

	/*********************************************************/
	function GetPagesByPageType($pagetypeid) {

		$o_page = new CPage();

		$sql  = "SELECT * FROM pages ";
		$sql .= "WHERE page_type_id='".$pagetypeid."' ";
		$sql .= "AND ref_id='0' ";
		$sql .= "ORDER BY order_id";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_pagearray = new CPageArray();
			while ($row = $db->get_row()) {
				$o_page = new CPage($row);
				$o_pagearray->add($o_page);
			}
			$db->db_disconnect();
		}
		return $o_pagearray;
	}

	/*********************************************************/
	function InsertPage($CPage) {

		$sql = "INSERT INTO pages ";
		$sql .= "( ";
			$sql .= "ref_id, ";
			$sql .= "description, ";
			$sql .= "keywords, ";
			$sql .= "alias, ";
			$sql .= "active, ";
			$sql .= "menu_item, ";
			$sql .= "topmenu_item, ";
			$sql .= "page_type_id ";
		$sql .= ") ";
		$sql .= "VALUES";
		$sql .= "( ";
			$sql .= "'".$CPage->ref_id."', ";
			$sql .= "'".$CPage->description."', ";
			$sql .= "'".$CPage->keywords."', ";
			$sql .= "'".$CPage->alias."', ";
			$sql .= "'".$CPage->active."', ";
			$sql .= "'".$CPage->menu_item."', ";
			$sql .= "'".$CPage->topmenu_item."', ";
			$sql .= "'".$CPage->page_type_id."' ";
		$sql .= ") ";
		//echo "SQL:".$sql."<br>";

		$last_record = 0;
		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$last_record = $db->getLastRecord();
			$db->db_disconnect();				
		}
		return $last_record;
	}

	/*********************************************************/
	function UpdatePage($CPage) {

		$sql = "UPDATE pages ";
		$sql .= "SET ";
		$sql .= "description = '".$CPage->description."', ";
		$sql .= "keywords = '".$CPage->keywords."', ";
		$sql .= "alias = '".$CPage->alias."', ";
		$sql .= "active = '".$CPage->active."', ";
		$sql .= "menu_item = '".$CPage->menu_item."', ";
		$sql .= "topmenu_item = '".$CPage->topmenu_item."', ";
		$sql .= "ref_id = '".$CPage->ref_id."', ";
		$sql .= "order_id = '".$CPage->order_id."', ";
		$sql .= "page_type_id = '".$CPage->page_type_id."' ";
		$sql .= "WHERE page_id='".$CPage->page_id."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$db->db_disconnect();				
		}
		else return false;
		
		return true;		
	}

	/*********************************************************/
	function DeletePage($page_id) {

		$sql = "DELETE FROM pages ";
		$sql .= "WHERE page_id='".$page_id."'";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()) {
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else 
			return false;
		
		return true;
	}

	/*********************************************************/
	function DeletePageByRef($page_id) {

		$sql = "DELETE FROM pages ";
		$sql .= "WHERE ref_id='".$page_id."'";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()) {
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else 
			return false;
		
		return true;
	}

	/*******************************************************************************
	* PageTypes
	********************************************************************************
	* function GetPageType()						: CPageType
	* function GetPageTypes()						: CPageTypeArray
	********************************************************************************/
	function GetPageType($page_type_id) {

		$sql  = "SELECT * FROM page_types ";
		$sql .= "WHERE page_type_id='".$page_type_id."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_pagetype = new CPageType($row);
			}
			$db->db_disconnect();
		}
			return $o_pagetype;
	}


	/*********************************************************/
	function GetPageTypes($active) {

		$o_pagetype = new CPageType();

		$sql  = "SELECT * FROM page_types ";
		if ($active==1)
			$sql .= "WHERE active='1' ";
		else
			$sql .= "WHERE active='0' ";
		$sql .= "ORDER BY page_type_id";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_pagetypearray = new CPageTypeArray();
			while ($row = $db->get_row()) {
				$o_pagetype = new CPageType($row);
				$o_pagetypearray->add($o_pagetype);
			}
			$db->db_disconnect();
		}
		return $o_pagetypearray;
	}

	/*******************************************************************************
	* Contents
	********************************************************************************
	* function GetContentByName()				: CContent
	* function UpdateContent()					: Boolean
	* function InsertContent()					: Last_Record
	* function UpdateContent()					: Boolean
	* function DeleteContent()					: Boolean
	********************************************************************************/
	function GetContent($language, $page_id, $typeofcontent) {

		$sql  = "SELECT * FROM contents ";
		$sql .= "WHERE page_id='".$page_id."' ";
		$sql .= "AND lang='".strtolower($language)."' ";
		if ($typeofcontent == 'name')
			$sql .= "AND type='name' ";
		else
			$sql .= "AND type='content' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_content = new CContent($row);
			}
			$db->db_disconnect();
		}
			return $o_content;
	}

	/*********************************************************/
	function InsertContent($CContent, $typeofcontent) {

		$sql = "INSERT INTO contents ";
		$sql .= "( ";
			$sql .= "page_id, ";
			$sql .= "lang, ";
			$sql .= "type, ";
			$sql .= "context ";
		$sql .= ") ";
		$sql .= "VALUES";
		$sql .= "( ";
			$sql .= "'".$CContent->page_id."', ";
			$sql .= "'".$CContent->lang."', ";
			if ($typeofcontent == 'name')
				$sql .= "'name', ";
			else
				$sql .= "'content', ";
			$sql .= "'".$CContent->context."' ";
		$sql .= ") ";

		//echo "SQL:".$sql."<br>";

		$last_record = 0;
		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$last_record = $db->getLastRecord();
			$db->db_disconnect();				
		}
		return $last_record;
	}

	/*********************************************************/
	function UpdateContent($language, $CContent, $typeofcontent) {

		$sql = "UPDATE contents ";
		$sql .= "SET ";
		$sql .= "context = '".$CContent->context."', ";
		$sql .= "hit_counter = '".$CContent->hit_counter."' ";
		$sql .= "WHERE page_id='".$CContent->page_id."' ";
		$sql .= "AND lang='".strtolower($language)."' ";
		if ($typeofcontent == 'name')
			$sql .= "AND type='name' ";
		else
			$sql .= "AND type='content' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$db->db_disconnect();				
		}
		else return false;
		
		return true;		
	}

	/*********************************************************/
	function DeleteContent($page_id) {

		$sql = "DELETE FROM contents ";
		$sql .= "WHERE page_id='".$page_id."'";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()) {
			$db->db_query($sql);
			$db->db_disconnect();
		}
		else 
			return false;
		
		return true;
	}


	/*******************************************************************************
	* Styles
	********************************************************************************
	* function GetStyle()							: CStyle
	* function GetActiveStyle()					: CStyle
	********************************************************************************/
	function GetStyle($style_id) {

		$sql  = "SELECT * FROM styles ";
		$sql .= "WHERE style_id='".$style_id."' ";
		//$sql .= "AND active='1'";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_style = new CStyle($row);
			}
			$db->db_disconnect();
		}
			return $o_style;
	}

	/*********************************************************/
	function GetActiveStyle() {

		$sql  = "SELECT * FROM styles ";
		$sql .= "WHERE active='1'";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_style = new CStyle($row);
			}
			$db->db_disconnect();
		}
			return $o_style;
	}

	/*********************************************************/
	function UpdateStyle($CStyle) {

		$sql = "UPDATE styles ";
		$sql .= "SET ";
		$sql .= "name = '".$CStyle->name."', ";
		$sql .= "bgcol = '".$CStyle->bgcol."', ";
		$sql .= "bgim = '".$CStyle->bgim."', ";
		$sql .= "bgrep = '".$CStyle->bgrep."', ";
		$sql .= "bgpos = '".$CStyle->bgpos."', ";
		$sql .= "font = '".$CStyle->font."', ";
		$sql .= "fsize = '".$CStyle->fsize."', ";
		$sql .= "fcol = '".$CStyle->fcol."', ";
		$sql .= "hsize = '".$CStyle->hsize."', ";

		$sql .= "hcol = '".$CStyle->hcol."', ";
		$sql .= "hbgcol = '".$CStyle->hbgcol."', ";
		$sql .= "hbgim = '".$CStyle->hbgim."', ";
		$sql .= "hbgrep = '".$CStyle->hbgrep."', ";
		$sql .= "hbgpos = '".$CStyle->hbgpos."', ";
		$sql .= "docbgcol = '".$CStyle->docbgcol."', ";
		$sql .= "docbgim = '".$CStyle->docbgim."', ";
		$sql .= "docbgrep = '".$CStyle->docbgrep."', ";
		$sql .= "docbgpos = '".$CStyle->docbgpos."', ";
		$sql .= "docborstyle = '".$CStyle->docborstyle."', ";

		$sql .= "docborw = '".$CStyle->docborw."', ";
		$sql .= "docborcol = '".$CStyle->docborcol."', ";
		$sql .= "mmbgcol = '".$CStyle->mmbgcol."', ";
		$sql .= "mmborstyle = '".$CStyle->mmborstyle."', ";
		$sql .= "mmborw = '".$CStyle->mmborw."', ";
		$sql .= "mmborcol = '".$CStyle->mmborcol."', ";
		$sql .= "mmfcol = '".$CStyle->mmfcol."', ";
		$sql .= "mmhcol = '".$CStyle->mmhcol."', ";
		$sql .= "smbgcol = '".$CStyle->smbgcol."', ";
		$sql .= "smborstyle = '".$CStyle->smborstyle."', ";
		$sql .= "smborw = '".$CStyle->smborw."', ";

		$sql .= "smborcol = '".$CStyle->smborcol."', ";
		$sql .= "smfcol = '".$CStyle->smfcol."', ";
		$sql .= "smhcol = '".$CStyle->smhcol."', ";
		$sql .= "ah = '".$CStyle->ah."', ";
		$sql .= "al = '".$CStyle->al."', ";
		$sql .= "av = '".$CStyle->av."', ";
		$sql .= "active = '".$CStyle->active."' ";

		$sql .= "WHERE style_id='".$CStyle->style_id."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$db->db_disconnect();				
		}
		else return false;
		
		return true;		
	}

	/*******************************************************************************
	* ContactUs Messages
	********************************************************************************
	* function GetAdminMessage()						: CAdminMessage
	* function GetAdminMessages()						: CAdminMessageArray
	********************************************************************************/
	function GetContactUsMessage($contact_us_id) {

		$sql  = "SELECT * FROM contact_us ";
		$sql .= "WHERE contact_us_id='".$contact_us_id."' ";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			while ($row = $db->get_row()) {
				$o_contactus = new CContactUs($row);
			}
			$db->db_disconnect();
		}
			return $o_contactus;
	}


	/*********************************************************/
	function GetContactUsMessages() {

		$o_contactus = new CContactUs();

		$sql  = "SELECT * FROM contact_us ";
		$sql .= "ORDER BY contact_us_id";
		//echo "SQL:".$sql."<br>";

		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$o_contactusarray = new CContactUsArray();
			while ($row = $db->get_row()) {
				$o_contactus = new CContactUs($row);
				$o_contactusarray->add($o_contactus);
			}
			$db->db_disconnect();
		}
		return $o_contactusarray;
	}

	/*********************************************************/
	function InsertContactUsMessage($CContactUs) {

		$sql = "INSERT INTO contact_us ";
		$sql .= "( ";
			$sql .= "active, ";
			$sql .= "read_message, ";
			$sql .= "published, ";
			$sql .= "post_name, ";
			$sql .= "post_email, ";
			$sql .= "post_header, ";
			$sql .= "post_content, ";
			$sql .= "post_date, ";
			$sql .= "read_date, ";
			$sql .= "sent_reply, ";
			$sql .= "reply_header, ";
			$sql .= "reply_content, ";
			$sql .= "reply_date ";
		$sql .= ") ";
		$sql .= "VALUES";
		$sql .= "( ";
			$sql .= "'".$CContactUs->active."', ";
			$sql .= "'".$CContactUs->read_message."', ";
			$sql .= "'".$CContactUs->published."', ";
			$sql .= "'".$CContactUs->post_name."', ";
			$sql .= "'".$CContactUs->post_email."', ";
			$sql .= "'".$CContactUs->post_header."', ";
			$sql .= "'".$CContactUs->post_content."', ";
			$sql .= "'".$CContactUs->post_date."', ";
			$sql .= "'".$CContactUs->read_date."', ";
			$sql .= "'".$CContactUs->sent_reply."', ";
			$sql .= "'".$CContactUs->reply_header."', ";
			$sql .= "'".$CContactUs->reply_content."', ";
			$sql .= "'".$CContactUs->reply_date."' ";
		$sql .= ") ";
		//echo "SQL:".$sql."<br>";

		$last_record = 0;
		$db = new db();
		$db->db_connect();
		if ($db->is_connected()){
			$db->db_query($sql);
			$last_record = $db->getLastRecord();
			$db->db_disconnect();				
		}
		return $last_record;
	}

/*******************************************************************************
* End of DataAccess Object Page
********************************************************************************/
}
?>
Return current item: ChiCoMaS - Chilek CMS