Skip to content

Commit

Permalink
Merge pull request #7 from minimus/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
minimus committed Jan 2, 2014
2 parents d66e23f + b73cd7e commit 29a6f80
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 142 deletions.
8 changes: 8 additions & 0 deletions admin.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ public function onDeactivate() {
$pTable = $wpdb->prefix . "sam_places";
$aTable = $wpdb->prefix . "sam_ads";
$bTable = $wpdb->prefix . "sam_blocks";
$eTable = $wpdb->prefix . "sam_errors";
$sTable = $wpdb->prefix . "sam_stats";
$settings = parent::getSettings();

if($settings['deleteOptions'] == 1) {
Expand All @@ -89,6 +91,8 @@ public function onDeactivate() {
$wpdb->query($sql.$pTable);
$wpdb->query($sql.$aTable);
$wpdb->query($sql.$bTable);
$wpdb->query($sql.$eTable);
$wpdb->query($sql.$sTable);
delete_option('sam_db_version');
}
if($settings['deleteFolder'] == 1) {
Expand All @@ -102,6 +106,8 @@ public function onUninstall() {
$pTable = $wpdb->prefix . "sam_places";
$aTable = $wpdb->prefix . "sam_ads";
$bTable = $wpdb->prefix . "sam_blocks";
$eTable = $wpdb->prefix . "sam_errors";
$sTable = $wpdb->prefix . "sam_stats";

delete_option( SAM_OPTIONS_NAME );
delete_option('sam_version');
Expand All @@ -112,6 +118,8 @@ public function onUninstall() {
$wpdb->query($sql.$pTable);
$wpdb->query($sql.$aTable);
$wpdb->query($sql.$bTable);
$wpdb->query($sql.$eTable);
$wpdb->query($sql.$sTable);

if(is_dir(SAM_AD_IMG)) rmdir(SAM_AD_IMG);
}
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: https://load.payoneer.com/[email protected]
Tags: ad, adbrite, adgridwork, adify, admin, adpinion, adroll, ads, adsense, adserver, advertisement, advertising, affiliate, banner, banners, chitika, cj, commercial, commission, crispads, dfp, google, income, junction, link, manager, media, money, plugin, random, referral, revenue, rotator, seo, server, shoppingads, widget, widgetbucks, yahoo, ypn
Requires at least: 3.5
Tested up to: 3.8
Stable tag: 1.8.72
Stable tag: 2.0.74
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -87,7 +87,9 @@ No questions now...

== Changelog ==

= 1.8.72 =
= 2.0.74 =
* Minor bug is resolved
= 2.0.73 =
* Javascript output of ads (for caching compatibility) is added
* Custom Taxonomies restrictions are added
* Building query for SQL request is optimised
Expand Down Expand Up @@ -182,6 +184,8 @@ No questions now...

== Upgrade Notice ==

= 2.0.74 =
Minor bug is resolved
= 1.8.72 =
Caching plugins compatibility, bbPress compatibility, Custom Taxonomies restrictions, etc.
= 1.7.63 =
Expand Down
4 changes: 2 additions & 2 deletions sam.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class SimpleAdsManager {
);

public function __construct() {
define('SAM_VERSION', '1.8.72');
define('SAM_DB_VERSION', '2.5');
define('SAM_VERSION', '2.0.74');
define('SAM_DB_VERSION', '2.6');
define('SAM_PATH', dirname( __FILE__ ));
define('SAM_URL', plugins_url( '/', __FILE__ ) );
define('SAM_IMG_URL', SAM_URL.'images/');
Expand Down
2 changes: 1 addition & 1 deletion simple-ads-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Simple Ads Manager
Plugin URI: http://www.simplelib.com/?p=480
Description: "Simple Ads Manager" is easy to use plugin providing a flexible logic of displaying advertisements. Visit <a href="http://www.simplelib.com/">SimpleLib blog</a> for more details.
Version: 1.8.72
Version: 2.0.74
Author: minimus
Author URI: http://blogcoding.ru
*/
Expand Down
166 changes: 29 additions & 137 deletions updater.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ private function errorWrite($eTable, $rTable, $eSql = null, $eResult = null, $la
}
}

private function getCreateSql( $table, $defTable ) {
global $charset_collate;

$add = '';
$primaryKey = '';

foreach($defTable as $key => $val) {
$add .= ((empty($add)) ? '' : ', ')
. $key . ' ' . $val['Type']
. (($val['Null'] == 'NO') ? ' NOT NULL' : '')
. ((empty($val['Default'])) ? '' : ' DEFAULT ' . (($val['Extra'] == 'str') ? "'{$val['Default']}'" : $val['Default']))
. (($val['Extra'] == 'auto_increment') ? ' AUTO_INCREMENT' : '' );
if($val['Key'] == 'PRI') $primaryKey .= ((empty($primaryKey)) ? '' : ', ') . $key;
}

if(!empty($add)) {
$add .= ((!empty($primaryKey)) ? ", PRIMARY KEY ({$primaryKey})" : '');
$out = "CREATE TABLE {$table} ({$add}) {$charset_collate};";
}
else $out = '';

return $out;
}

private function getUpdateSql($table, $defTable) {
global $wpdb, $charset_collate;
$dbv = $this->dbVersion;
Expand Down Expand Up @@ -241,25 +265,7 @@ public function update() {

// Place Table
if($wpdb->get_var("SHOW TABLES LIKE '$pTable'") != $pTable) {
$pSql = "CREATE TABLE $pTable (
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
description VARCHAR(255) DEFAULT NULL,
code_before VARCHAR(255) DEFAULT NULL,
code_after VARCHAR(255) DEFAULT NULL,
place_size VARCHAR(25) DEFAULT NULL,
place_custom_width INT(11) DEFAULT NULL,
place_custom_height INT(11) DEFAULT NULL,
patch_img VARCHAR(255) DEFAULT NULL,
patch_link VARCHAR(255) DEFAULT NULL,
patch_code TEXT DEFAULT NULL,
patch_adserver TINYINT(1) DEFAULT 0,
patch_dfp VARCHAR(255) DEFAULT NULL,
patch_source TINYINT(1) DEFAULT 0,
patch_hits INT(11) DEFAULT 0,
trash TINYINT(1) DEFAULT 0,
PRIMARY KEY (id)
) $charset_collate;";
$pSql = self::getCreateSql($pTable, $sam_tables_defs['places']);
dbDelta($pSql);
}
else {
Expand All @@ -274,71 +280,7 @@ public function update() {

// Ads Table
if($wpdb->get_var("SHOW TABLES LIKE '$aTable'") != $aTable) {
$aSql = "CREATE TABLE $aTable (
id INT(11) NOT NULL AUTO_INCREMENT,
pid INT(11) NOT NULL,
name VARCHAR(255) DEFAULT NULL,
description VARCHAR(255) DEFAULT NULL,
code_type TINYINT(1) NOT NULL DEFAULT 0,
code_mode TINYINT(1) NOT NULL DEFAULT 1,
ad_code TEXT DEFAULT NULL,
ad_img TEXT DEFAULT NULL,
ad_alt TEXT DEFAULT NULL,
ad_title varchar(255) DEFAULT NULL,
ad_no TINYINT(1) NOT NULL DEFAULT 0,
ad_target TEXT DEFAULT NULL,
ad_swf tinyint(1) DEFAULT 0,
ad_swf_flashvars text,
ad_swf_params text,
ad_swf_attributes text,
count_clicks TINYINT(1) NOT NULL DEFAULT 0,
ad_users tinyint(1) DEFAULT 0,
ad_users_unreg tinyint(1) DEFAULT 0,
ad_users_reg tinyint(1) DEFAULT 0,
x_ad_users tinyint(1) DEFAULT NULL,
x_view_users TEXT DEFAULT NULL,
ad_users_adv tinyint(1) DEFAULT 0,
view_type INT(11) DEFAULT 1,
view_pages SET('isHome','isSingular','isSingle','isPage','isAttachment','isSearch','is404','isArchive','isTax','isCategory','isTag','isAuthor','isDate','isPostType','isPostTypeArchive') DEFAULT NULL,
view_id TEXT DEFAULT NULL,
ad_cats TINYINT(1) DEFAULT 0,
view_cats TEXT DEFAULT NULL,
ad_authors TINYINT(1) DEFAULT 0,
view_authors TEXT DEFAULT NULL,
ad_tags TINYINT(1) DEFAULT 0,
view_tags TEXT DEFAULT NULL,
ad_custom TINYINT(1) DEFAULT 0,
view_custom TEXT DEFAULT NULL,
x_id TINYINT(1) DEFAULT 0,
x_view_id TEXT DEFAULT NULL,
x_cats TINYINT(1) DEFAULT 0,
x_view_cats TEXT DEFAULT NULL,
x_authors TINYINT(1) DEFAULT 0,
x_view_authors TEXT DEFAULT NULL,
x_tags TINYINT(1) DEFAULT 0,
x_view_tags TEXT DEFAULT NULL,
x_custom TINYINT(1) DEFAULT 0,
x_view_custom TEXT DEFAULT NULL,
ad_schedule TINYINT(1) DEFAULT 0,
ad_start_date DATE DEFAULT NULL,
ad_end_date DATE DEFAULT NULL,
limit_hits TINYINT(1) DEFAULT 0,
hits_limit INT(11) DEFAULT 0,
limit_clicks TINYINT(1) DEFAULT 0,
clicks_limit INT(11) DEFAULT 0,
ad_hits INT(11) DEFAULT 0,
ad_clicks INT(11) DEFAULT 0,
ad_weight INT(11) DEFAULT 10,
ad_weight_hits INT(11) DEFAULT 0,
adv_nick varchar(50) DEFAULT NULL,
adv_name varchar(100) DEFAULT NULL,
adv_mail varchar(50) DEFAULT NULL,
cpm DECIMAL(10,2) UNSIGNED DEFAULT 0.00,
cpc DECIMAL(10,2) UNSIGNED DEFAULT 0.00,
per_month DECIMAL(10,2) UNSIGNED DEFAULT 0.00,
trash TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (id, pid)
) $charset_collate;";
$aSql = self::getCreateSql($aTable, $sam_tables_defs['ads']);
dbDelta($aSql);
}
else {
Expand All @@ -355,33 +297,7 @@ public function update() {

// Zones Table
if($wpdb->get_var("SHOW TABLES LIKE '$zTable'") != $zTable) {
$zSql = "CREATE TABLE $zTable (
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
description VARCHAR(255) DEFAULT NULL,
z_default INT(11) DEFAULT 0,
z_home INT(11) DEFAULT 0,
z_singular INT(11) DEFAULT 0,
z_single INT(11) DEFAULT 0,
z_ct INT(11) DEFAULT 0,
z_single_ct LONGTEXT DEFAULT NULL,
z_page INT(11) DEFAULT 0,
z_attachment INT(11) DEFAULT 0,
z_search INT(11) DEFAULT 0,
z_404 INT(11) DEFAULT 0,
z_archive INT(11) DEFAULT 0,
z_tax INT(11) DEFAULT 0,
z_category INT(11) DEFAULT 0,
z_cats LONGTEXT DEFAULT NULL,
z_tag INT(11) DEFAULT 0,
z_author INT(11) DEFAULT 0,
z_authors LONGTEXT DEFAULT NULL,
z_date INT(11) DEFAULT 0,
z_cts INT(11) DEFAULT 0,
z_archive_ct LONGTEXT DEFAULT NULL,
trash TINYINT(1) DEFAULT 0,
PRIMARY KEY (id)
) $charset_collate;";
$zSql = self::getCreateSql($zTable, $sam_tables_defs['zones']);
dbDelta($zSql);
}
else {
Expand All @@ -396,24 +312,7 @@ public function update() {

// Blocks Table
if($wpdb->get_var("SHOW TABLES LIKE '$bTable'") != $bTable) {
$bSql = "CREATE TABLE $bTable (
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
description VARCHAR(255) DEFAULT NULL,
b_lines INT(11) DEFAULT 2,
b_cols INT(11) DEFAULT 2,
block_data LONGTEXT DEFAULT NULL,
b_margin VARCHAR(30) DEFAULT '5px 5px 5px 5px',
b_padding VARCHAR(30) DEFAULT '5px 5px 5px 5px',
b_background VARCHAR(30) DEFAULT '#FFFFFF',
b_border VARCHAR(30) DEFAULT '0px solid #333333',
i_margin VARCHAR(30) DEFAULT '5px 5px 5px 5px',
i_padding VARCHAR(30) DEFAULT '5px 5px 5px 5px',
i_background VARCHAR(30) DEFAULT '#FFFFFF',
i_border VARCHAR(30) DEFAULT '0px solid #333333',
trash TINYINT(1) DEFAULT 0,
PRIMARY KEY (id)
) $charset_collate;";
$bSql = self::getCreateSql($bTable, $sam_tables_defs['blocks']);
dbDelta($bSql);
}
else {
Expand All @@ -428,14 +327,7 @@ public function update() {

// Statistics Table
if($wpdb->get_var("SHOW TABLES LIKE '$sTable'") != $sTable) {
$sSql = "CREATE TABLE $sTable (
id int(10) UNSIGNED DEFAULT NULL,
pid int(10) UNSIGNED DEFAULT NULL,
event_time datetime DEFAULT NULL,
event_type tinyint(1) DEFAULT NULL
)
$charset_collate
COMMENT = 'Simple Ads Manager Statistics';";
$sSql = self::getCreateSql($sTable, $sam_tables_defs['stats']);
dbDelta($sSql);
}
else {
Expand Down

0 comments on commit 29a6f80

Please sign in to comment.