<?php
/*-----------------------------------------------------------------
* 	ID:						cseov25_qf11.php
* 	Letzter Stand:			v2.5
* 	zuletzt geaendert von:	akausch
* 	Datum:					2014/04/08
*
* 	Copyright (c) since 2010 commerce:SEO by Webdesign Erfurt
* 	http://www.commerce-seo.de
* ---------------------------------------------------------------*/

class cseov25_qf11 {
var $title, $output;

function cseov25_qf11() {
  $this->code = 'cseov25_qf11';
  $this->version = '2.5.11';
  $this->title = 'cseov25_qf11';
  $this->description = 'Fix5.11 für commerce:seo v2next 2.5.10';
  $this->enabled = ((MODULE_CSEO_V251QF11_STATUS == 'true') ? true : false);
  $this->sort_order = MODULE_CSEO_V251QF11_SORT_ORDER;

  $this->output = array();
}

function process() {
  global $order, $xtPrice;
}

function check() {
  if (!isset($this->_check)) {
	$check_query = xtc_db_query("SELECT configuration_value FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'MODULE_CSEO_V251QF11_STATUS'");
	$this->_check = xtc_db_num_rows($check_query);
  }
  return $this->_check;
}

function keys() {
	return array('MODULE_CSEO_V251QF11_STATUS', 'MODULE_CSEO_V251QF11_SORT_ORDER');
}

function install() {
	xtc_db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_key, configuration_value,configuration_group_id, sort_order, set_function, date_added) VALUES ('MODULE_CSEO_V251QF11_STATUS', 'true', '6', '1','', now())");
	xtc_db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_key, configuration_value,configuration_group_id, sort_order, date_added) VALUES ('MODULE_CSEO_V251QF11_SORT_ORDER', '1','6', '2', now())");
	xtc_db_query("INSERT INTO " . TABLE_CONFIGURATION . " (configuration_key, configuration_value,configuration_group_id, sort_order, date_added) VALUES ('MODULE_CSEO_V251QF11', 'true','6', '3', now())");
	//SEO Config
	$check_query = xtc_db_query("SELECT cseo_key FROM cseo_configuration  WHERE cseo_key = 'SEOLYZEEMAIL';");
	if (xtc_db_num_rows($check_query) == 0) {
		xtc_db_query("INSERT INTO cseo_configuration (cseo_key, cseo_group_id, cseo_sort_order) VALUES ('SEOLYZEEMAIL', 2, 1);");
		xtc_db_query("INSERT INTO cseo_configuration (cseo_key, cseo_group_id, cseo_sort_order) VALUES ('SEOLYZEVORNAME', 2, 2);");
		xtc_db_query("INSERT INTO cseo_configuration (cseo_key, cseo_group_id, cseo_sort_order) VALUES ('SEOLYZENACHNAME', 2, 3);");
		xtc_db_query("INSERT INTO cseo_configuration (cseo_key, cseo_group_id, cseo_sort_order) VALUES ('SEOLYZETELE', 2, 4);");
		xtc_db_query("INSERT INTO cseo_configuration (cseo_key, cseo_group_id, cseo_sort_order) VALUES ('SEOLYZEAPIKEY', 2, 5);");
	}
	//Admin
	if (!column_exists ('admin_access','cseo_seolyze')) {
		@xtc_db_query("ALTER TABLE admin_access ADD COLUMN cseo_seolyze INT(1) NOT NULL DEFAULT '0';");
		@xtc_db_query("UPDATE admin_access SET cseo_seolyze = 1;");
	}

	//Fehlende Navi
	$check_query = xtc_db_query("SELECT name FROM admin_navigation WHERE name = 'cseo_seolyze';");
	if (xtc_db_num_rows($check_query) == 0) {
		$lang_other = xtc_db_query("SELECT languages_id FROM languages;");
		if (xtc_db_num_rows($lang_other) > 0) {
			while ($other_lang = xtc_db_fetch_array($lang_other)) {
				$language_id = $other_lang['languages_id'];
				xtc_db_query("INSERT INTO admin_navigation VALUES (NULL, 'cseo_seolyze', 'SEOLYZE', 'seo_tools', 'cseo_seolyze.php', NULL, ".$language_id.", NULL, 1);");
			}
		}
	}
	
	//Fehlende Config
	$check_query = xtc_db_query("SELECT configuration_key FROM " . TABLE_CONFIGURATION . "  WHERE configuration_key = 'PAYPAL_PAYMENT_MODE';");
	if (xtc_db_num_rows($check_query) == 0) {
		xtc_db_query("INSERT INTO configuration VALUES (NULL, 'PAYPAL_PAYMENT_MODE', 'Sale', 25, 1, NULL, NOW(), NULL, \"xtc_cfg_select_option(array('Sale', 'Authorization'),\");");
	}
	$check_query = xtc_db_query("SELECT configuration_key FROM " . TABLE_CONFIGURATION . "  WHERE configuration_key = 'DISPLAY_START_NEW_PRODUCTS';");
	if (xtc_db_num_rows($check_query) == 0) {
		xtc_db_query("INSERT INTO configuration VALUES (NULL, 'DISPLAY_START_NEW_PRODUCTS', 'top', 1000, 50, NULL, NOW(), NULL, \"xtc_cfg_select_option(array('top', 'newproducts'),\");");
	}
	if (!column_exists ('blog_items','canonical')) {
		xtc_db_query("ALTER TABLE blog_items ADD COLUMN canonical varchar(250) NOT NULL DEFAULT '';");
	}
	if (!column_exists ('blog_items','calender')) {
		@xtc_db_query("ALTER TABLE blog_items ADD COLUMN calender INT(5) NOT NULL DEFAULT '0' AFTER item_id;");
	}
	if (!column_exists ('blog_items','datestart')) {
		@xtc_db_query("ALTER TABLE blog_items ADD COLUMN datestart DATE NOT NULL AFTER date_release;");
	}
	if (!column_exists ('blog_items','dateend')) {
		@xtc_db_query("ALTER TABLE blog_items ADD COLUMN dateend DATE NOT NULL AFTER datestart;");
	}
	if (!column_exists ('blog_items','slider_set')) {
		@xtc_db_query("ALTER TABLE blog_items ADD COLUMN slider_set INT(11) NOT NULL DEFAULT '0' AFTER categories_id;");
	}
	if (!column_exists ('blog_categories','itemsort')) {
		xtc_db_query("ALTER TABLE blog_categories ADD COLUMN itemsort int(11) NOT NULL DEFAULT '1' AFTER sort_order;");
	}
	if (!column_exists ('blog_categories','itemsortart')) {
		xtc_db_query("ALTER TABLE blog_categories ADD COLUMN itemsortart int(11) NOT NULL DEFAULT '1' AFTER sort_order;");
	}
	if (!column_exists ('blog_categories','slider_set')) {
		xtc_db_query("ALTER TABLE blog_categories ADD COLUMN slider_set int(11) NOT NULL DEFAULT '0';");
	}
	if (!column_exists ('blog_categories','canonical')) {
		xtc_db_query("ALTER TABLE blog_categories ADD COLUMN canonical varchar(250) NOT NULL DEFAULT '';");
	}
	if (!column_exists ('blog_start','slider_set')) {
		xtc_db_query("ALTER TABLE blog_start ADD COLUMN slider_set int(11) NOT NULL DEFAULT '0';");
	}
	if (!column_exists ('cseo_slider_gallery','slider_mobile')) {
		xtc_db_query("ALTER TABLE cseo_slider_gallery ADD COLUMN slider_mobile int(1) NOT NULL DEFAULT '1';");
	}
	if (!column_exists ('cseo_slider_gallery','slider_nav_status')) {
		xtc_db_query("ALTER TABLE cseo_slider_gallery ADD COLUMN slider_nav_status int(1) NOT NULL DEFAULT '1';");
	}
	if (!column_exists ('cseo_slider_gallery','slider_url_6')) {
		@xtc_db_query("ALTER TABLE cseo_slider_gallery
			ADD COLUMN slider_url_6 VARCHAR(255) NOT NULL AFTER slider_url_5,
			ADD COLUMN slider_image_6 VARCHAR(255) NOT NULL AFTER slider_image_5,
			ADD COLUMN slider_link_text_6 VARCHAR(255) NOT NULL AFTER slider_link_text_5,
			ADD COLUMN slider_desc_6 TEXT NULL AFTER slider_desc_5;");
	}
	if (!column_exists ('cseo_slider_gallery','slider_url_7')) {
		@xtc_db_query("ALTER TABLE cseo_slider_gallery
			ADD COLUMN slider_url_7 VARCHAR(255) NOT NULL AFTER slider_url_6,
			ADD COLUMN slider_image_7 VARCHAR(255) NOT NULL AFTER slider_image_6,
			ADD COLUMN slider_link_text_7 VARCHAR(255) NOT NULL AFTER slider_link_text_6,
			ADD COLUMN slider_desc_7 TEXT NULL AFTER slider_desc_6;");
	}
	if (!column_exists ('cseo_slider_gallery','slider_url_8')) {
		@xtc_db_query("ALTER TABLE cseo_slider_gallery
			ADD COLUMN slider_url_8 VARCHAR(255) NOT NULL AFTER slider_url_7,
			ADD COLUMN slider_image_8 VARCHAR(255) NOT NULL AFTER slider_image_7,
			ADD COLUMN slider_link_text_8 VARCHAR(255) NOT NULL AFTER slider_link_text_7,
			ADD COLUMN slider_desc_8 TEXT NULL AFTER slider_desc_7;");
	}
	
	xtc_db_query("UPDATE admin_navigation SET title = 'magnalister' WHERE title = 'Magnalister';");
	xtc_db_query("DELETE FROM configuration WHERE configuration_key = 'AJAXJYOUTUBE';");
	xtc_db_query("UPDATE database_version SET version = 'commerce:seo v2next 2.5.11'");
	

}

function remove() {
  xtc_db_query("DELETE FROM " . TABLE_CONFIGURATION . " WHERE configuration_key in ('" . implode("', '", $this->keys()) . "')");
  xtc_db_query("DELETE FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'MODULE_CSEO_V251QF11'");
  xtc_db_query("UPDATE database_version SET version = 'commerce:seo v2next 2.5.10'");
}

}
