Skip to content

Commit

Permalink
New Version 1.0.3
Browse files Browse the repository at this point in the history
* Fix: Fixed Some Bugs Generated due to adrotate plugin update.
  • Loading branch information
iamdharmesh committed Feb 17, 2016
1 parent 06a8e86 commit c309bf3
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 24 deletions.
8 changes: 4 additions & 4 deletions ad-rotate-email-addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

/**
* Plugin Name: AdRotater Email Add-on
* Plugin URI: http://xylusinfo.com/
* Plugin URI: http://xylusthemes.com/
* Description: This is a add-on plugin for Add Rotate, this Plugin has functionality to send Emails to Advertisers.
* Version: 1.0.1
* Author: Xylus Consultancy Services
* Author URI: http://xylusinfo.com/
* Version: 1.0.3
* Author: Xylus Themes
* Author URI: http://xylusthemes.com/
* License: GPLv2 or later
* Text Domain: add-rotate-email-addon
* Domain Path: /languages
Expand Down
82 changes: 73 additions & 9 deletions admin/ad-rotate-email-main.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@
* admin side of the site.
*/

if (isset( $_POST['adrotate_email_advertiser_nonce'] )&& wp_verify_nonce( $_POST['adrotate_email_advertiser_nonce'], 'adrotate_email_advertiser' )){
if(isset($_POST['dsp_advertiser']) && $_POST['dsp_advertiser'] != ''){
global $wpdb;
$advertiser_id = $_POST['dsp_advertiser'];
if($advertiser_id == '-1'){
?>
<script> alert("Please Select Advertiser !!!");</script>
<?php

}else{
$ad_id = $_POST['dsp_ad_id'];
$edit_id = $wpdb->get_var("SELECT `meta_id` FROM `".$wpdb->prefix."adsmeta` WHERE `ad` = $ad_id AND `meta_key` = 'advertiser';");

if(isset($edit_id) && $edit_id != ''){
$wpdb->update($wpdb->prefix."adsmeta", array('meta_value' => $advertiser_id),array( 'meta_id' => $edit_id ));

}else{
$wpdb->insert($wpdb->prefix."adsmeta", array('ad' => $ad_id, 'meta_key' => 'advertiser', 'meta_value' => $advertiser_id));
//$edit_id = $wpdb->insert_id;
}
}
}
}

if (isset($_GET['message']) && $_GET['message'] == 'error'){
?>
<div class="error">
Expand Down Expand Up @@ -59,14 +83,15 @@
<h2><?php _e('Email Management', 'ad-rotate-email-addon'); ?></h2>
<?php
// Fetch all Ad Banners
$allbanners = $wpdb->get_results("SELECT `id`, `title`, `type`, `tracker`, `weight`, `cbudget`, `ibudget`, `crate`, `irate` FROM `".$wpdb->prefix."adrotate` WHERE `type` = 'active' OR `type` = 'error' OR `type` = 'expired' OR `type` = '2days' OR `type` = '7days' OR `type` = 'disabled' ORDER BY `sortorder` ASC, `id` ASC;");
$allbanners = $wpdb->get_results("SELECT `id`, `title`, `type`, `tracker`, `weight`, `budget`, `crate`, `irate` FROM `".$wpdb->prefix."adrotate` WHERE `type` = 'active' OR `type` = 'error' OR `type` = 'expired' OR `type` = '2days' OR `type` = '7days' OR `type` = 'disabled' ORDER BY `sortorder` ASC, `id` ASC;");

$activebanners1 = $errorbanners = $disabledbanners = false;
foreach($allbanners as $singlebanner) {
$advertiser = '';
$starttime = $stoptime = 0;
$starttime = $wpdb->get_var("SELECT `starttime` FROM `".$wpdb->prefix."adrotate_schedule` WHERE `ad` = '".$singlebanner->id."' ORDER BY `starttime` ASC LIMIT 1;");
$stoptime = $wpdb->get_var("SELECT `stoptime` FROM `".$wpdb->prefix."adrotate_schedule` WHERE `ad` = '".$singlebanner->id."' ORDER BY `stoptime` DESC LIMIT 1;");

$starttime = $wpdb->get_var("SELECT `starttime` FROM `".$wpdb->prefix."adrotate_schedule`, `".$wpdb->prefix."adrotate_linkmeta` WHERE `ad` = '".$singlebanner->id."' AND `schedule` = `".$wpdb->prefix."adrotate_schedule`.`id` ORDER BY `starttime` ASC LIMIT 1;");
$stoptime = $wpdb->get_var("SELECT `stoptime` FROM `".$wpdb->prefix."adrotate_schedule`, `".$wpdb->prefix."adrotate_linkmeta` WHERE `ad` = '".$singlebanner->id."' AND `schedule` = `".$wpdb->prefix."adrotate_schedule`.`id` ORDER BY `stoptime` DESC LIMIT 1;");
if($adrotate_config['enable_advertisers'] == 'Y') {
$user = $wpdb->get_var("SELECT `user` FROM `".$wpdb->prefix."adrotate_linkmeta` WHERE `ad` = '".$singlebanner->id."' AND `group` = '0' AND `block` = '0' LIMIT 1;");
$advertiser = $wpdb->get_var("SELECT `user_login` FROM `".$wpdb->prefix."users` WHERE `id` = '".$user."' LIMIT 1;");
Expand All @@ -76,7 +101,7 @@
if($type == 'active' AND $stoptime <= $in7days) $type = '7days';
if($type == 'active' AND $stoptime <= $in2days) $type = '2days';
if($type == 'active' AND $stoptime <= $now) $type = 'expired';
if(($singlebanner->crate > 0 AND $singlebanner->cbudget < 1) OR ($singlebanner->irate > 0 AND $singlebanner->ibudget < 1)) $type = 'expired';
if(($singlebanner->crate > 0 AND $singlebanner->budget < 1) OR ($singlebanner->irate > 0 AND $singlebanner->budget < 1)) $type = 'expired';

//Active ads
if($type == 'active' OR $type == '7days') {
Expand Down Expand Up @@ -155,7 +180,9 @@
$id = $banner['id'];
$ad_title = $banner['title'];
$tracker = $banner['tracker'];
$users = Ad_Rotate_Email_Addon_Admin::find_user($id);
$ad_rotate_email = new Ad_Rotate_Email_Addon();
$ad_rotate_email_admin = new Ad_Rotate_Email_Addon_Admin($ad_rotate_email->get_ad_rotate_email_addon(),$ad_rotate_email->get_version() );
$users = $ad_rotate_email_admin->find_user($id);

foreach($users as $user){
$user_name = $user['user_login'];
Expand All @@ -164,23 +191,60 @@
}


?>
?></form>
<tr>

<th class="check-column"><input type="checkbox" name="bannercheck[]" value="<?php echo $id; ?>" /></th>
<td><?php echo $id; ?></td>
<td><?php echo date_i18n("F d, Y", $banner['firstactive']);?></td>
<td><span style="color: <?php echo adrotate_prepare_color($banner['lastactive']);?>;"><?php echo date_i18n("F d, Y", $banner['lastactive']);?></span></td>
<td><?php if($tracker=='Y'){ echo $display_name;}?></td>
<form name="advertiser_form" method="post" action="admin.php?page=adrotate_email">
<?php wp_nonce_field('adrotate_email_advertiser','adrotate_email_advertiser_nonce'); ?>
<td>

<?php
global $wpdb;
$select_id = (int)$wpdb->get_var("SELECT `meta_value` FROM `".$wpdb->prefix."adsmeta` WHERE `ad` = $id AND `meta_key` = 'advertiser';");
$args = array(
'name' => 'dsp_advertiser',
'show_option_none' => 'Select Advertiser'
);
if(isset($select_id) && $select_id != ''){
$args['selected'] = $select_id;
$button_text = __('Change', 'add-rotate-email-addon');
}else{
$button_text = __('Add', 'add-rotate-email-addon');
}
?>
<input type="hidden" name="dsp_ad_id" value="<?php echo $id; ?>">
<?php wp_dropdown_users( $args ); ?>
<input type="submit" class="button-primary" value="<?php echo $button_text; ?>" />


</td>
</form>
<td>
<strong><a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-ads&view=edit&ad='.$banner['id']);?>" title="<?php _e('Edit', 'adrotate'); ?>"><?php echo $ad_title; ?></a></strong> - <a href="<?php echo admin_url('/admin.php?page=adrotate-ads&view=report&ad='.$banner['id']);?>" title="<?php _e('Stats', 'adrotate'); ?>"><?php _e('Stats', 'adrotate'); ?></a> - <a href="admin.php?page=adrotate-schedules&ad=<?php echo $banner['id']; ?>"><?php _e('Schedules', 'adrotate'); ?></a><span style="color:#999;"><?php if(strlen($grouplist) > 0) echo '<br /><span style="font-weight:bold;">Groups:</span> '.$grouplist; ?><?php if(strlen($banner['advertiser']) > 0 AND $adrotate_config['enable_advertisers'] == 'Y') echo '<br /><span style="font-weight:bold;">Advertiser:</span> '.$banner['advertiser']; ?></span>
<strong>
<a class="row-title" href="<?php echo admin_url('/admin.php?page=adrotate-ads&view=edit&ad='.$banner['id']);?>" title="<?php _e('Edit', 'adrotate'); ?>">
<?php echo $ad_title; ?>
</a>
</strong>
- <a href="<?php echo admin_url('/admin.php?page=adrotate-ads&view=report&ad='.$banner['id']);?>" title="<?php _e('Stats', 'add-rotate-email-addon'); ?>">
<?php _e('Stats', 'add-rotate-email-addon'); ?>
</a>
- <a href="admin.php?page=adrotate-schedules&ad=<?php echo $banner['id']; ?>">
<?php _e('Schedules', 'add-rotate-email-addon'); ?>
</a>
<span style="color:#999;">
<?php if(strlen($banner['advertiser']) > 0 AND $adrotate_config['enable_advertisers'] == 'Y') echo '<br /><span style="font-weight:bold;">Advertiser:</span> '.$banner['advertiser']; ?>
</span>
</td>
<td><?php if($tracker=='Y'){ echo $stats['impressions'];}?></td>
<td><?php if($tracker=='Y'){ echo $stats_today['impressions'];}?></td>
<td><?php if($tracker=='Y'){ echo $stats['clicks'];}?></td>
<td><?php if($tracker=='Y'){ echo $stats_today['clicks'];}?></td>
<td><?php if($tracker=='Y'){ echo $stats_today['clicks'];}?></td>
</form>

<form name="inner_emails" id="post" method="post" action="admin.php?page=adrotate_email">
<?php wp_nonce_field('adrotate_email_ad_active_inner','adrotate_email_nonce_inner'); ?>
<input type="hidden" name="ad_id" value="<?php echo $id; ?>" >
Expand Down
8 changes: 4 additions & 4 deletions admin/class-ad-rotate-email-addon-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ public function enqueue_scripts() {

}

public function dsp_wordpress_dashboard(){
add_submenu_page('adrotate', 'AdRotate > '.__('Email', 'adrotate'), __('Email', 'adrotate'), 'adrotate_ad_manage', 'adrotate_email', array(Ad_Rotate_Email_Addon_Admin,'dsp_ad_rotate_email'));
public static function dsp_wordpress_dashboard(){
add_submenu_page('adrotate', 'AdRotate > '.__('Email', 'adrotate'), __('Email', 'adrotate'), 'adrotate_ad_manage', 'adrotate_email', array('Ad_Rotate_Email_Addon_Admin','dsp_ad_rotate_email'));
}

/*-------------------------------------------------------------
Expand All @@ -112,7 +112,7 @@ public function dsp_wordpress_dashboard(){
Receive: -none-
Return: -none-
-------------------------------------------------------------*/
public function dsp_ad_rotate_email(){
public static function dsp_ad_rotate_email(){
include("ad-rotate-email-main.php");
}

Expand All @@ -128,7 +128,7 @@ public function find_user($id){
return $users;
}

public function dsp_enable_option(){
public static function dsp_enable_option(){
register_setting('dsp_option_group','dsp_subject');
register_setting('dsp_option_group','dsp_from');
register_setting('dsp_option_group','dsp_from_email');
Expand Down
31 changes: 30 additions & 1 deletion includes/class-ad-rotate-email-addon-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,35 @@ class Ad_Rotate_Email_Addon_Activator{
*
* @since 1.0.0
*/
public function table_install(){
global $wpdb;
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');

public function activate() {
if ($wpdb->has_cap('collation')) {

if (!empty($wpdb->charset))
$charset_collate = " DEFAULT CHARACTER SET $wpdb->charset";
if (!empty($wpdb->collate))
$charset_collate .= " COLLATE $wpdb->collate";
}

$engine = '';
$found_engine = $wpdb->get_var("SELECT ENGINE FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = '" . DB_NAME . "' AND `TABLE_NAME` = '" . $wpdb->prefix . "posts';");
if (strtolower($found_engine) == 'innodb') {
$engine = ' ENGINE=InnoDB';
}

dbDelta("CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."adsmeta` (
`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`ad` bigint(20) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar(255) DEFAULT NULL,
`meta_value` longtext,
PRIMARY KEY (`meta_id`)
) " . $charset_collate . $engine . ";");
}


public function activate() {
/**
* Set Options for Email template and Subject
*/
Expand All @@ -52,6 +79,8 @@ public function activate() {
update_option( 'dsp_cc', $email);
update_option( 'dsp_reply', $email);

Ad_Rotate_Email_Addon_Activator::table_install();

}
}

2 changes: 1 addition & 1 deletion includes/class-ad-rotate-email-addon-send-email.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function send_email($id,$month) {
$ads = $wpdb->get_results( $wpdb->prepare( "SELECT `thetime`, SUM(`clicks`) as `clicks`, SUM(`impressions`) as `impressions` FROM `" . $wpdb->prefix . "adrotate_stats` WHERE (`thetime` >= '" . $from . "' AND `thetime` <= '" . $until . "') AND `ad` = %d GROUP BY `thetime` ASC;", $id ), ARRAY_A );

$title = $wpdb->get_var( $wpdb->prepare( "SELECT `title` FROM `" . $wpdb->prefix . "adrotate` WHERE `id` = %d;", $id ) );
$user_id = $wpdb->get_var( $wpdb->prepare( "SELECT `user` FROM `" . $wpdb->prefix . "adrotate_linkmeta` WHERE `ad` = %d;", $id ) );
$user_id = $wpdb->get_var("SELECT `meta_value` FROM `".$wpdb->prefix."adsmeta` WHERE `ad` = $id AND `meta_key` = 'advertiser';");
$user = $wpdb->get_results( $wpdb->prepare( "SELECT `user_email`,`display_name` FROM `" . $wpdb->prefix . "users` WHERE `ID` = %d;", $user_id ), ARRAY_A );

$useremail = $user[0]['user_email'];
Expand Down
2 changes: 1 addition & 1 deletion includes/class-ad-rotate-email-addon.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Ad_Rotate_Email_Addon {
public function __construct() {

$this->ad_rotate_email_addon = 'ad-rotate-email-addon';
$this->version = '1.0.1';
$this->version = '1.0.3';

$this->load_dependencies();
$this->set_locale();
Expand Down
13 changes: 9 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
=== Adrotater Email Add-on ===
Contributors: xylus
Donate link: http://xylusinfo.com/
Contributors: xylus, karangadhavi
Donate link: http://xylusthemes.com/
Tags: ad,ads,email,adrotate,adrotate add-on,banner, commercial, admin, advertise, adrotator, 2014, plugin,rotator,advertiser, publisher, adsense,automatic email,statistics, stats, report, advert, adverts,javascript, jquery, tracking, clicks, impressions, rotate,add-on,addon,best,great,mail
Requires at least: 3.8, PHP5.3
Tested up to: 4.1
Stable tag: 1.0.1
Tested up to: 4.3
Stable tag: 1.0.3
License: GPLv2 or later

Adrotater Email add-on is an add-on plugin for AdRotate plugin. This plugin adds Email functionality to Adrotate Plugin
Expand Down Expand Up @@ -48,4 +48,9 @@ No, You must need a [AdRotate](https://wordpress.org/plugins/adrotate/) plugin t
* Added: Reply To option.


= 1.0.2 =
* Added: Add Advertiser Functionality

= 1.0.3 =
* Fix: Fixed Some Bugs Generated due to adrotate plugin update.

10 changes: 10 additions & 0 deletions uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}

global $wpdb;
$wpdb->query("DROP TABLE IF EXISTS `".$wpdb->prefix."adsmeta`");

delete_option('dsp_email_template');
delete_option('dsp_subject');
delete_option('dsp_from');
delete_option('dsp_from_email');
delete_option('dsp_cc');
delete_option('dsp_reply');

0 comments on commit c309bf3

Please sign in to comment.