Esempio n. 1
0
 public function form_fields()
 {
     $form_fields = array(array('title' => __('Reference ID', APP_TD), 'type' => 'text', 'name' => 'cp_sys_ad_conf_id', 'default' => cp_generate_id(), 'extra' => array('readonly' => 'readonly')), array('title' => __('Views Today', APP_TD), 'type' => 'text', 'name' => 'cp_daily_count', 'sanitize' => 'absint', 'default' => '0', 'extra' => array('readonly' => 'readonly')), array('title' => __('Views Total', APP_TD), 'type' => 'text', 'name' => 'cp_total_count', 'sanitize' => 'absint', 'default' => '0', 'extra' => array('readonly' => 'readonly')), array('title' => __('Submitted from IP', APP_TD), 'type' => 'text', 'name' => 'cp_sys_userIP', 'default' => appthemes_get_ip(), 'extra' => array('readonly' => 'readonly')));
     if (cp_payments_is_enabled()) {
         $form_fields[] = array('title' => __('Last Payment', APP_TD), 'type' => 'text', 'name' => 'cp_sys_total_ad_cost', 'default' => '0', 'desc' => APP_Currencies::get_current_symbol(), 'extra' => array('readonly' => 'readonly'));
     }
     return $form_fields;
 }
Esempio n. 2
0
     $price_curr = $cp_options->curr_symbol;
 }
 // keep only values and insert/strip commas if needed
 if (!empty($_POST['tags_input'])) {
     $postvals['tags_input'] = appthemes_clean_tags($_POST['tags_input']);
     $_POST['tags_input'] = $postvals['tags_input'];
 }
 // store the user IP address, ID for later
 $postvals['cp_sys_userIP'] = appthemes_get_ip();
 $postvals['user_id'] = $current_user->ID;
 $ad_pack_id = isset($_POST['ad_pack_id']) ? appthemes_numbers_only($_POST['ad_pack_id']) : false;
 if ($ad_pack_id) {
     $postvals['pack_duration'] = cp_get_ad_pack_length($ad_pack_id);
 }
 $coupon = false;
 if (cp_payments_is_enabled()) {
     // see if the featured ad checkbox has been checked
     if (isset($_POST['featured_ad'])) {
         $postvals['featured_ad'] = $_POST['featured_ad'];
         // get the featured ad price into the array
         $postvals['cp_sys_feat_price'] = $cp_options->sys_feat_price;
     }
     // calculate the ad listing fee and put into a variable
     $postvals['cp_sys_ad_listing_fee'] = cp_ad_listing_fee($_POST['cat'], $ad_pack_id, $postvals['cp_price'], $price_curr);
     // calculate the total cost of the ad
     if (isset($postvals['cp_sys_feat_price'])) {
         $postvals['cp_sys_total_ad_cost'] = cp_calc_ad_cost($_POST['cat'], $ad_pack_id, $postvals['cp_sys_feat_price'], $postvals['cp_price'], $coupon, $price_curr);
     } else {
         $postvals['cp_sys_total_ad_cost'] = cp_calc_ad_cost($_POST['cat'], $ad_pack_id, 0, $postvals['cp_price'], $coupon, $price_curr);
     }
     //UPDATE TOTAL BASED ON MEMBERSHIP
    } else {
        _e('Membership Updated', APP_TD);
    }
    ?>
                </h2>
            
                <img src="<?php 
    echo appthemes_locate_template_uri('images/step3.gif');
    ?>
" alt="" class="stepimg" />
            
                <div class="thankyou">
            
                    <?php 
    // call in the selected payment gateway as long as the price isn't zero
    if (cp_payments_is_enabled() && $order['total_cost'] > 0) {
        $membership_order = appthemes_new_order();
        $membership_order->add_item(CP_ITEM_MEMBERSHIP, $order['total_cost']);
        do_action('appthemes_create_order', $membership_order);
        echo html('h3', __('Payment', APP_TD));
        echo html('p', __('Please wait while we redirect you to our payment page.', APP_TD));
        echo html('p', html('small', __('(Click the button below if you are not automatically redirected within 5 seconds.)', APP_TD)));
        cp_js_redirect($membership_order->get_return_url(), __('Continue to Payment', APP_TD));
        //process the "free" orders on this page
    } else {
        $order_processed = appthemes_process_membership_order($current_user, $order);
        //send email to user
        if ($order_processed) {
            cp_owner_activated_membership_email($current_user, $order_processed);
        }
        ?>
function cp_category_dropdown_price($category, $args)
{
    global $cp_options;
    if ($cp_options->price_scheme != 'category' || !cp_payments_is_enabled()) {
        return '';
    }
    if ($cp_options->ad_parent_posting == 'no' && $category->parent == 0) {
        return '';
    }
    if ($cp_options->ad_parent_posting == 'whenEmpty' && $category->parent == 0) {
        $child_terms = get_terms($args['taxonomy'], array('parent' => $category->term_id, 'number' => 1, 'hide_empty' => 0));
        if (!empty($child_terms)) {
            return '';
        }
    }
    $prices = $cp_options->price_per_cat;
    $cat_price = isset($prices[$category->term_id]) ? (double) $prices[$category->term_id] : 0;
    return ' - ' . appthemes_get_price($cat_price);
}
Esempio n. 5
0
/**
 * Displays the non-custom fields below the main listing submission form.
 *
 * @param int $listing_id
 *
 * @return void
 */
function cp_other_fields($listing_id)
{
    global $cp_options;
    // are images on ads allowed
    if ($cp_options->ad_images) {
        if (appthemes_plupload_is_enabled()) {
            echo html('div class="ad-details-images-sep"', '&nbsp;');
            appthemes_plupload_form($listing_id);
        } else {
            $images_count = cp_get_ad_images($listing_id);
            cp_ad_edit_image_input_fields($images_count);
        }
    }
    // show the chargeable options if enabled
    if (cp_payments_is_enabled()) {
        // show the featured ad box if enabled
        if ($cp_options->sys_feat_price) {
            ?>

			<div class="ad-details-featured-sep"></div>

			<li id="list_featured_ad" class="withborder">
				<div class="labelwrapper">
					<label><?php 
            printf(__('Featured Listing %s', APP_TD), appthemes_get_price($cp_options->sys_feat_price));
            ?>
</label>
				</div>
				<div class="clr"></div>
				<input name="featured_ad" value="1" type="checkbox" <?php 
            checked(is_sticky($listing_id));
            ?>
 />
				<?php 
            _e('Your listing will appear in the featured slider section at the top of the front page.', APP_TD);
            ?>
				<div class="clr"></div>
			</li>

		<?php 
        }
        if ($cp_options->price_scheme == 'single') {
            ?>

			<li>
				<div class="labelwrapper">
					<label><?php 
            _e('Ad Package:', APP_TD);
            ?>
</label>
				</div>

				<?php 
            // go get all the active ad packs and create a drop-down of options
            $packages = cp_get_listing_packages();
            if ($packages) {
                ?>

					<select name="ad_pack_id" class="dropdownlist required">

					<?php 
                foreach ($packages as $package) {
                    // external plugins can modify or disable field
                    $result = apply_filters('cp_package_field', $package, 'ad');
                    if (!$package) {
                        continue;
                    }
                    ?>
							<option value="<?php 
                    echo esc_attr($package->ID);
                    ?>
"><?php 
                    echo esc_attr($package->pack_name);
                    ?>
</option>
						<?php 
                }
                ?>

					</select>

				<?php 
            } else {
                _e('Error: no ad pack has been defined. Please contact the site administrator.', APP_TD);
            }
            ?>

				<div class="clr"></div>
			</li>

		<?php 
        }
        ?>

	<?php 
    }
}
 function cp_set_post_status($advals)
 {
     global $wpdb, $cp_options;
     if ($cp_options->post_status == 'pending') {
         return 'pending';
     }
     if (cp_payments_is_enabled() && $advals['cp_sys_total_ad_cost'] > 0) {
         return 'pending';
     }
     return 'publish';
 }
Esempio n. 7
0
				
                
				<div id="ad-categories-footer" class="button-container">
					<input type="submit" name="getcat" id="getcat" class="btn_orange" value="<?php 
                _e('Go &rsaquo;&rsaquo;', APP_TD);
                ?>
" />
					<div id="chosenCategory"><input id="ad_cat_id" name="cat" type="hidden" value="15" /></div>
					<div style="clear:both;"></div>
				</div>
				<div style="clear:both;"></div>
			</li>

			<?php 
            } else {
                if ($cp_options->price_scheme == 'category' && cp_payments_is_enabled()) {
                    $prices = $cp_options->price_per_cat;
                    $cat_fee = isset($prices[$category->term_id]) ? (double) $prices[$category->term_id] : 0;
                    $cat_fee = ' - ' . appthemes_get_price($cat_fee);
                } else {
                    $cat_fee = '';
                }
                ?>

			<li>
				<div class="labelwrapper"><label><?php 
                _e('Category:', APP_TD);
                ?>
</label></div>
				<strong><?php 
                echo $category->name;
Esempio n. 8
0
/**
 * Returns url of order connected to given Post ID.
 *
 * @param int $post_id
 * @return string
 */
function cp_get_order_permalink($post_id)
{
    if (!cp_payments_is_enabled()) {
        return;
    }
    $order = appthemes_get_order_connected_to($post_id);
    if (!$order) {
        return;
    }
    return appthemes_get_order_url($order->get_id());
}
Esempio n. 9
0
	

	<div class="processlog">
		<?php 
    // insert the ad and get back the post id
    $renew_id = isset($_GET['renew']) ? $_GET['renew'] : false;
    //var_dump($advals);
    $post_id = cp_add_new_listing($advals, $renew_id);
    ?>
	</div>
	<div class="thankyou">

		<?php 
    // call in the selected payment gateway as long as the price isn't zero
    if (cp_payments_is_enabled() && $advals['cp_sys_total_ad_cost'] > 0) {
        $order = appthemes_new_order();
        $order->add_item(CP_ITEM_LISTING, $advals['cp_sys_total_ad_cost'], $post_id);
        do_action('appthemes_create_order', $order);
        echo html('h3', __('Payment', APP_TD));
        echo html('p', __('Please wait while we redirect you to our payment page.', APP_TD));
        echo html('p', html('small', __('(Click the button below if you are not automatically redirected within 5 seconds.)', APP_TD)));
        cp_js_redirect($order->get_return_url(), __('Continue to Payment', APP_TD));
    } else {
        // otherwise the ad was free and show the thank you page.
        // get the post status
        $the_post = get_post($post_id);
        // check to see what the ad status is set to
        if ($the_post->post_status == 'pending') {
            // send ad owner an email
            cp_owner_new_ad_email($post_id);
Esempio n. 10
0
 function template_redirect()
 {
     appthemes_require_login(array('login_text' => __('You must first login to purchase a membership.', APP_TD), 'login_register_text' => __('You must first login or <a href="%s">register</a> to purchase a membership.', APP_TD)));
     // redirect to dashboard if payments disabled
     if (!cp_payments_is_enabled('membership')) {
         appthemes_add_notice('payments-disabled', __('Payments are currently disabled. You cannot purchase anything.', APP_TD), 'error');
         wp_redirect(CP_DASHBOARD_URL);
         exit;
     }
     // load up the relavent javascript
     add_action('wp_enqueue_scripts', 'cp_load_form_scripts');
 }
Esempio n. 11
0
/**
 * Calculates the total ad cost.
 *
 * @param int $category_id
 * @param int $package_id
 * @param float $featuredprice
 * @param float $cp_price
 * @param string $cp_coupon (deprecated)
 * @param string $price_curr
 *
 * @return float
 */
function cp_calc_ad_cost($category_id, $package_id, $featuredprice, $cp_price, $cp_coupon, $price_curr)
{
    if (!cp_payments_is_enabled()) {
        return 0;
    }
    // check for deprecated argument
    if (!empty($cp_coupon)) {
        _deprecated_argument(__FUNCTION__, '3.3');
    }
    // calculate the listing fee price
    $adlistingfee = cp_ad_listing_fee($category_id, $package_id, $cp_price, $price_curr);
    // calculate the total cost for the ad.
    $totalcost_out = $adlistingfee + $featuredprice;
    //set proper return format
    $totalcost_out = number_format($totalcost_out, 2, '.', '');
    //if total cost is less then zero, then make the cost zero (free)
    if ($totalcost_out < 0) {
        $totalcost_out = 0;
    }
    return $totalcost_out;
}
Esempio n. 12
0
function cp_custom_fields_meta_box()
{
    global $wpdb, $post, $meta_boxes;
    // use nonce for verification
    wp_nonce_field(basename(__FILE__), 'ad_meta_wpnonce', false, true);
    // get the ad category id
    $ad_cat_id = appthemes_get_custom_taxonomy($post->ID, APP_TAX_CAT, 'term_id');
    // get the form id
    $fid = cp_get_form_id($ad_cat_id);
    // if there's no form id it must mean the default form is being used so let's go grab those fields
    if (!$fid) {
        // use this if there's no custom form being used and give us the default form
        $sql = "SELECT field_label, field_name, field_type, field_values, field_tooltip, field_req FROM {$wpdb->cp_ad_fields} WHERE field_core = '1' ORDER BY field_id asc";
    } else {
        // now we should have the formid so show the form layout based on the category selected
        $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, f.field_values, f.field_perm, f.field_tooltip, m.meta_id, m.field_pos, m.field_req, m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "ORDER BY m.field_pos asc", $fid);
    }
    $results = $wpdb->get_results($sql);
    // display the write panel for the custom fields
    if ($results) {
        ?>

	<script type="text/javascript">
		//<![CDATA[	
		/* initialize the datepicker feature */
		jQuery(document).ready(function($) {
			$('table input#datepicker').datetimepicker({
				showSecond: true,
				timeFormat: 'hh:mm:ss',
				showOn: 'button',
				dateFormat: 'yy-mm-dd',
				minDate: 0,
				buttonImageOnly: true,
				buttonText: '',
				buttonImage: '../wp-includes/images/blank.gif' // calling the real calendar image in the admin.css. need a blank placeholder image b/c of IE.
			});
		});
		//]]>
	</script>

		<table class="form-table ad-meta-table">

			<tr>
				<th style="width:20%"><label for="cp_sys_ad_conf_id"><?php 
        _e('Ad Info', APP_TD);
        ?>
:</label></th>
				<td class="ad-conf-id">
					<div id="ad-id"><div id="keyico"></div><?php 
        _e('Ad ID', APP_TD);
        ?>
: <span><?php 
        echo esc_html(get_post_meta($post->ID, 'cp_sys_ad_conf_id', true));
        ?>
</span></div>
					<div id="ad-stats"><div id="statsico"></div><?php 
        _e('Views Today', APP_TD);
        ?>
: <strong><?php 
        echo esc_html(get_post_meta($post->ID, 'cp_daily_count', true));
        ?>
</strong> | <?php 
        _e('Views Total:', APP_TD);
        ?>
 <strong><?php 
        echo esc_html(get_post_meta($post->ID, 'cp_total_count', true));
        ?>
</strong></div>
				</td>
			</tr>

			<tr>
				<th style="width:20%"><label for="cp_sys_ad_conf_id"><?php 
        _e('Submitted By', APP_TD);
        ?>
:</label></th>
				<td style="line-height:3.4em;">
					<?php 
        // show the gravatar for the author
        echo get_avatar($post->post_author, $size = '48', $default = '');
        // show the author drop-down box
        wp_dropdown_users(array('who' => 'authors', 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author, 'include_selected' => true));
        // display the author display name
        $author = get_userdata($post->post_author);
        echo '<br/><a href="user-edit.php?user_id=' . $author->ID . '">' . $author->display_name . '</a>';
        ?>
				</td>
			</tr>

			<?php 
        if (cp_payments_is_enabled()) {
            ?>
				<tr>
					<th style="width:20%"><label for="cp_sys_total_ad_cost"><?php 
            _e('Ad Terms', APP_TD);
            ?>
:</label></th>
					<td><?php 
            printf(__('%1$s for %2$s days', APP_TD), appthemes_get_price(get_post_meta($post->ID, 'cp_sys_total_ad_cost', true)), get_post_meta($post->ID, 'cp_sys_ad_duration', true));
            ?>
</td>
				</tr>
			<?php 
        } else {
            ?>
				<tr>
					<th style="width:20%"><label for="cp_sys_ad_duration"><?php 
            _e('Duration', APP_TD);
            ?>
:</label></th>
					<td><?php 
            printf(__('Listed for %s days', APP_TD), get_post_meta($post->ID, 'cp_sys_ad_duration', true));
            ?>
</td>
				</tr>
			<?php 
        }
        ?>

			<tr>
				<th style="width:20%"><label for="cp_sys_expire_date"><?php 
        _e('Ad Expires', APP_TD);
        ?>
:</label></th>
				<td><input readonly type="text" name="cp_sys_expire_date" class="text" id="datepicker" value="<?php 
        echo esc_attr(get_post_meta($post->ID, 'cp_sys_expire_date', true));
        ?>
" /></td>
			</tr>

			<tr>
				<th colspan="2" style="padding:0px;">&nbsp;</th>
			</tr>

			<?php 
        cp_edit_ad_fields($results, $post->ID);
        // build the edit ad meta box
        ?>


			<tr>
				<th style="width:20%"><label for="cp_sys_userIP"><?php 
        _e('Submitted from IP', APP_TD);
        ?>
:</label></th>
				<td><?php 
        echo esc_html(get_post_meta($post->ID, 'cp_sys_userIP', true));
        ?>
</td>
			</tr>

		</table>

	<?php 
    }
    ?>

<?php 
}
_e('Total Amount Due:', APP_TD);
?>
</label></div>
				<div id="review"><strong><?php 
if ($membership->pack_membership_price > 0) {
    appthemes_display_price($membership->pack_membership_price);
} else {
    _e('--', APP_TD);
}
?>
</strong></div>
				<div class="clr"></div>
			</li>

			<?php 
if (cp_payments_is_enabled() && $membership->pack_membership_price > 0) {
    do_action('appthemes_purchase_fields');
}
?>

		</ol>

		<div class="pad10"></div>

		<div class="license">
			<?php 
cp_display_message('terms_of_use');
?>
		</div>

		<div class="clr"></div>
Esempio n. 14
0
 function template_redirect()
 {
     // redirect to dashboard if payments disabled
     if (!cp_payments_is_enabled()) {
         appthemes_add_notice('payments-disabled', __('Payments are currently disabled. You cannot purchase anything.', APP_TD), 'error');
         wp_redirect(CP_DASHBOARD_URL);
         exit;
     }
     // if not logged in, redirect to login page
     if (!is_user_logged_in()) {
         //echo CP_MEMBERSHIP_SIGNUP;exit;
         wp_redirect(CP_MEMBERSHIP_SIGNUP);
     }
     //appthemes_auth_redirect_login();
     // this is needed for IE to work with the go back button
     header("Cache-control: private");
     // include all the functions needed for this form
     require_once get_template_directory() . '/includes/forms/step-functions.php';
     // load up the relavent javascript
     add_action('wp_enqueue_scripts', 'cp_load_form_scripts');
 }
Esempio n. 15
0
 /**
  * Processing form.
  *
  * @param object $order
  * @param object $checkout
  *
  * return void
  */
 public function process($order, $checkout)
 {
     global $cp_options;
     // if no listing internal ID move step backward
     $posted_fields = $checkout->get_data('posted_fields');
     if (!$posted_fields['cp_sys_ad_conf_id']) {
         $checkout->cancel_step();
         return;
     }
     if (!isset($_POST['action']) || !in_array($_POST['action'], array('create-listing', 'renew-listing'))) {
         return;
     }
     check_admin_referer($checkout->get_checkout_type());
     $this->posted_fields = $checkout->get_data('posted_fields');
     if (cp_payments_is_enabled()) {
         $this->errors = apply_filters('appthemes_validate_purchase_fields', $this->errors);
     }
     if ($this->errors->get_error_codes()) {
         return false;
     }
     $listing = $this->get_listing_obj();
     $this->update_listing($order, $checkout);
     if (cp_payments_is_enabled()) {
         $plan_id = isset($this->posted_fields['ad_pack_id']) ? $this->posted_fields['ad_pack_id'] : 0;
         $membership_id = isset($this->posted_fields['membership_pack']) ? $this->posted_fields['membership_pack'] : 0;
         $this->add_plan_to_order($order, $checkout, $plan_id, $membership_id, $listing->ID);
         $this->add_addons_to_order($order, $listing->ID, $membership_id);
         $this->set_order_description($order, $checkout, $listing->ID);
         do_action('appthemes_create_order', $order, APP_POST_TYPE);
     } else {
         if ('pending' == get_post_status($listing->ID)) {
             // send ad owner an email
             cp_owner_new_ad_email($listing->ID);
         }
     }
     // send new ad notification email to admin
     if ($cp_options->new_ad_email) {
         cp_new_ad_email($listing->ID);
     }
     $this->finish_step();
 }
Esempio n. 16
0
 function cp_set_post_status($advals)
 {
     global $cp_options;
     if ($cp_options->moderate_ads) {
         return 'pending';
     }
     if (cp_payments_is_enabled()) {
         return 'pending';
     }
     return 'publish';
 }