<?php

/**
 * @Package: WordPress Plugin
 * @Subpackage: Ultra Portfolio
 * @Since: Ultra Portfolio 1.0
 * @Current Version: Ultra Portfolio 3.1
 * @WordPress Version: 3.5 or above
 * This file is part of Ultra Portofolio WordPress Plugin.
 */
//Activation Code
function uport_activation() {
    global $wpdb;
    //global $uport_db_version;
//include("uport_demos.php");   
    $req = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "uport(
			id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
			step1val TEXT,
			step2val TEXT,
			step3val TEXT,
			step4val TEXT,
			step5val TEXT,
			step6val TEXT,
			step7val TEXT,
			updatedon VARCHAR (255),
			active INT(11)
			); ";
//	$wpdb->query($req);
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta($req);
    $req = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "uport_items(
			item_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
			item_title VARCHAR (255),
			item_link TEXT,
			item_description TEXT,
			item_slug VARCHAR (255),
			item_date VARCHAR (100),
			item_thumbnail TEXT,
			item_thumbnailembed TEXT,
			item_image TEXT,
			item_ext TEXT,
			item_extvideo TEXT,
			item_extaudio TEXT,
			item_extembed TEXT,
			item_exttype VARCHAR (200),
			item_price VARCHAR (200),
			item_category VARCHAR (255)
			); ";
//	$wpdb->query($req);
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta($req);

    $req = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "uport_categories(
			cat_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
			cat_name VARCHAR (100),
			cat_description TEXT
			);";
//	$wpdb->query($req);
    dbDelta($req);

if(file_exists(plugin_dir_path( __FILE__ ).'../lib/uport-multicat-index.mc.php')){
    $req = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix . "uport_categories_parent(
			id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
			cat_id INT (11),
			parent_id INT (11)
			);";
//	$wpdb->query($req);
    dbDelta($req);
}



    add_option("uport_db_version", "1.0");
}

//Deactivation Code
function uport_deactivation() {
    /* 	delete_option('uport_db_version');
      global $wpdb;
      $req = "DROP TABLE IF EXISTS " . $wpdb->prefix . "uport;";
      $wpdb->query($req);
      $req = "DROP TABLE IF EXISTS " . $wpdb->prefix . "uport_items;";
      $wpdb->query($req);
      $req = "DROP TABLE IF EXISTS " . $wpdb->prefix . "uport_categories;";
      $wpdb->query($req);
     */
}

?>