<?php
/*
Plugin Name: Mark As Read
Plugin URI: http://cgcookie.com
Description: Let users mark posts as read or unread, view a list of their unread posts and more
Version: 1.0
Author: CG Cookie, INC
Contributors: Pippin Williamson
Author URI: http://cgcookie.com 
*/

include('includes/display-functions.php');
include('includes/scripts.php');
include('includes/mark-as-read-functions.php');
include('includes/shortcodes.php');
include('includes/settings.php');
include('includes/dashboard-widgets.php');
include('includes/mar-widgets.php');
include('includes/profile-post-report.php');


// globals
global $wpdb;

// plugin root folder
global $mar_base_dir;
$mar_base_dir = WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "" , plugin_basename(__FILE__));

global $mar_options;
$mar_options = get_option('mar_settings');

// bookmark count table
global $mar_db_table;
$mar_db_table = $wpdb->prefix . "mar_read_counts";

// bookmark count table version
global $mar_table_version;
$mar_table_version = 1.0;


function mar_install()
{
	global $wpdb;
	global $mar_db_table;
	global $mar_table_version;
	
	if($wpdb->get_var("show tables like '$mar_db_table'") != $mar_db_table) 
	{
		$sql = "CREATE TABLE " . $mar_db_table . " (
		id mediumint(9) NOT NULL AUTO_INCREMENT,
		read_count mediumint NOT NULL,
		UNIQUE KEY id (id)
		);";
		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
		dbDelta($sql);
			
		add_option("mar_database_version", $mar_table_version);	
	}
}
register_activation_hook( __FILE__, 'mar_install' );