protected function generate_html($template_type = '')
 {
     $post_ids = array();
     foreach ($this->search_results['items'] as $item_id => $item_html) {
         $post_ids[] = $item_id;
     }
     $conditions = array();
     $conditions[] = "ad_id IN ( " . implode(',', $post_ids) . " ) ";
     $args = array();
     $ads = AWPCP_Ad::get_enabled_ads($args, $conditions);
     $parity = array('displayaditemseven', 'displayaditemsodd');
     if ('ajax' == $template_type) {
         $layout = buddyboss_global_search_buffer_template_part('loop/' . $this->type, $template_type, false);
     } else {
         $layout = get_awpcp_option('displayadlayoutcode');
         if (empty($layout)) {
             $layout = awpcp()->settings->get_option_default_value('displayadlayoutcode');
         }
     }
     if (!empty($ads)) {
         foreach ($ads as $i => $listing) {
             $rendered_listing = awpcp_do_placeholders($listing, $layout, $context);
             $rendered_listing = str_replace("\$awpcpdisplayaditems", $parity[$i % 2], $rendered_listing);
             if (function_exists('awpcp_featured_ads')) {
                 $rendered_listing = awpcp_featured_ad_class($listing->ad_id, $rendered_listing);
             }
             $rendered_listing = apply_filters('awpcp-render-listing-item', $rendered_listing, $i + 1, $template_type);
             $result = array('id' => $listing->ad_id, 'type' => $this->type, 'title' => $listing->ad_title, 'html' => $rendered_listing);
             $this->search_results['items'][$listing->ad_id] = $result;
         }
     }
 }
 public function restore_missing_pages()
 {
     $shortcodes = awpcp_pages();
     $missing_pages = $this->missing_pages_finder->find_missing_pages();
     $pages_to_restore = array_merge($missing_pages['not-found'], $missing_pages['not-referenced']);
     $page_refs = awpcp_get_properties($pages_to_restore, 'page');
     // If we are restoring the main page, let's do it first!
     if (($p = array_search('main-page-name', $page_refs)) !== FALSE) {
         // put the main page as the first page to restore
         array_splice($pages_to_restore, 0, 0, array($pages_to_restore[$p]));
         array_splice($pages_to_restore, $p + 1, 1);
     }
     $restored_pages = array();
     foreach ($pages_to_restore as $page) {
         $refname = $page->page;
         $name = get_awpcp_option($refname);
         if (strcmp($refname, 'main-page-name') == 0) {
             awpcp_create_pages($name, $subpages = false);
         } else {
             awpcp_create_subpage($refname, $name, $shortcodes[$refname][1]);
         }
         $restored_pages[] = $page;
     }
     update_option('awpcp-flush-rewrite-rules', true);
     return $restored_pages;
 }
Beispiel #3
0
 /**
  * Register Ad Management Panel menu
  */
 public function menu()
 {
     /* Profile Menu */
     // We are using read as an alias for edit_classifieds_listings. If a user can `read`,
     // he or she can `edit_classifieds_listings`.
     $capability = 'read';
     // Account Balance
     if (awpcp_payments_api()->credit_system_enabled() && !awpcp_current_user_is_admin()) {
         $parts = array($this->account->title, $this->account->menu, $this->account->page);
         $hook = add_users_page($parts[0], $parts[1], $capability, $parts[2], array($this->account, 'dispatch'));
         add_action("admin_print_styles-{$hook}", array($this->account, 'scripts'));
     }
     $current_user_is_non_admin_moderator = awpcp_current_user_is_moderator() && !awpcp_current_user_is_admin();
     if (get_awpcp_option('enable-user-panel') != 1 || $current_user_is_non_admin_moderator) {
         return;
     }
     /* Ad Management Menu */
     $slug = 'awpcp-panel';
     $title = sprintf(__('%s Ad Management Panel', 'AWPCP'), get_bloginfo());
     $menu = __('Ad Management', 'AWPCP');
     $hook = add_menu_page($title, $menu, $capability, $slug, array($this->listings, 'dispatch'), MENUICO);
     // Listings
     $title = __('Manage Ad Listings', 'AWPCP');
     $menu = __('Listings', 'AWPCP');
     $hook = add_submenu_page($slug, $title, $menu, $capability, $slug, array($this->listings, 'dispatch'));
     add_action("admin_print_styles-{$hook}", array($this->listings, 'scripts'));
     do_action('awpcp_panel_add_submenu_page', $slug, $capability);
 }
Beispiel #4
0
 public function notices()
 {
     if (!awpcp_current_user_is_admin()) {
         return;
     }
     if (awpcp_request_param('page', false) == 'awpcp-admin-upgrade') {
         return;
     }
     if (get_option('awpcp-pending-manual-upgrade')) {
         ob_start();
         include AWPCP_DIR . '/admin/templates/admin-pending-manual-upgrade-notice.tpl.php';
         $html = ob_get_contents();
         ob_end_clean();
         echo $html;
         return;
     }
     $show_quick_start_quide_notice = get_awpcp_option('show-quick-start-guide-notice');
     $show_drip_autoresponder = get_awpcp_option('show-drip-autoresponder');
     if ($show_quick_start_quide_notice && is_awpcp_admin_page() && !$show_drip_autoresponder) {
         ob_start();
         include AWPCP_DIR . '/admin/templates/admin-quick-start-guide-notice.tpl.php';
         $html = ob_get_contents();
         ob_end_clean();
         echo $html;
     }
     if (get_awpcp_option('show-widget-modification-notice')) {
         ob_start();
         include AWPCP_DIR . '/admin/templates/admin-widget-modification-notice.tpl.php';
         $html = ob_get_contents();
         ob_end_clean();
         echo $html;
     }
     do_action('awpcp-admin-notices');
 }
 public function render($params)
 {
     extract($params = wp_parse_args($params, array('context' => 'default', 'name' => 'category', 'label' => __('Ad Category', 'AWPCP'), 'required' => true, 'selected' => null, 'placeholders' => array())));
     if ($context == 'search') {
         $placeholders = array_merge(array('default-option-first-level' => __('All Categories', 'AWPCP'), 'default-option-second-level' => __('All Sub-categories', 'AWPCP')), $placeholders);
     } else {
         if (get_awpcp_option('noadsinparentcat')) {
             $second_level_option_placeholder = __('Select a Sub-category', 'AWPCP');
         } else {
             $second_level_option_placeholder = __('Select a Sub-category (optional)', 'AWPCP');
         }
         $placeholders = array_merge(array('default-option-first-level' => __('Select a Category', 'AWPCP'), 'default-option-second-level' => $second_level_option_placeholder), $placeholders);
     }
     $categories = awpcp_categories_collection()->get_all();
     $categories_hierarchy = awpcp_build_categories_hierarchy($categories);
     $chain = $this->get_category_parents($selected, $categories);
     $use_multiple_dropdowns = get_awpcp_option('use-multiple-category-dropdowns');
     // export categories list to JavaScript, but don't replace an existing categories list
     awpcp()->js->set('categories', $categories_hierarchy, false);
     ob_start();
     include AWPCP_DIR . '/frontend/templates/html-widget-category-dropdown.tpl.php';
     $content = ob_get_contents();
     ob_end_clean();
     return $content;
 }
Beispiel #6
0
 protected function get_panel_url()
 {
     if (awpcp_current_user_is_moderator() || !get_awpcp_option('enable-user-panel')) {
         return awpcp_get_admin_listings_url();
     }
     return awpcp_get_user_panel_url();
 }
 private function maybe_enable_listing($listing, $transaction, $trigger_actions)
 {
     if ($listing->disabled && $this->should_enable_listing($listing, $transaction)) {
         $should_approve_listing_images = get_awpcp_option('imagesapprove') ? false : true;
         $listing->enable($should_approve_listing_images, $trigger_actions);
     }
 }
 public function get_payment_terms()
 {
     global $wpdb;
     if (!awpcp_payments_api()->payments_enabled()) {
         return array($this->get_free_payment_term());
     }
     $order = get_awpcp_option('fee-order');
     $direction = get_awpcp_option('fee-order-direction');
     switch ($order) {
         case 1:
             $orderby = array('adterm_name', $direction);
             break;
         case 2:
             $orderby = array("amount {$direction}, adterm_name", $direction);
             break;
         case 3:
             $orderby = array("imagesallowed {$direction}, adterm_name", $direction);
             break;
         case 5:
             $orderby = array("_duration_interval {$direction}, rec_period {$direction}, adterm_name", $direction);
             break;
     }
     if (awpcp_current_user_is_admin()) {
         $args = array('orderby' => $orderby[0], 'order' => $orderby[1]);
     } else {
         $args = array('where' => 'private = 0', 'orderby' => $orderby[0], 'order' => $orderby[1]);
     }
     return AWPCP_Fee::query($args);
 }
Beispiel #9
0
function awpcp_users_field()
{
    if (get_awpcp_option('user-field-widget') == 'dropdown') {
        return awpcp_users_dropdown();
    } else {
        return awpcp_users_autocomplete();
    }
}
 public function validate_group_settings($options, $group)
 {
     if (isset($options['enable-email-verification']) && $options['enable-email-verification'] && get_awpcp_option('requireuserregistration')) {
         $message = __("Email verification was not enabled because Require Registration is on. Registered users don't need to verify the email address used for contact information.", 'AWPCP');
         awpcp_flash($message, 'error');
         $options['enable-email-verification'] = 0;
     }
     return $options;
 }
 private function normalize_query($user_query)
 {
     $query = wp_parse_args($user_query, array('context' => 'default', 'fields' => '*', 'raw' => false, 'id' => null, 'title' => null, 'keyword' => null, 'category_id' => null, 'exclude_category_id' => null, 'include_listings_in_children_categories' => true, 'user' => null, 'user_id' => null, 'contact_name' => null, 'price' => null, 'min_price' => null, 'max_price' => null, 'region' => '', 'country' => '', 'state' => '', 'city' => '', 'county' => '', 'regions' => array(), 'payment_status' => null, 'payer_email' => null, 'disabled_date' => null, 'end_date' => null, 'disabled' => null, 'verified' => null, 'featured' => null, 'flagged' => null, 'awaiting_approval' => null, 'have_media_awaiting_approval' => null, 'reviewed' => null, 'limit' => 0, 'offset' => 0, 'orderby' => 'default', 'order' => 'DESC'));
     if (!is_array($query['context'])) {
         $query['context'] = array($query['context']);
     }
     $query['regions'] = $this->normalize_regions_query($query);
     $query['limit'] = $query['limit'] === 0 ? get_awpcp_option('adresultsperpage', 10) : $query['limit'];
     return $query;
 }
 public function __construct($regions, $options)
 {
     // we need at least one region, even if its empty
     if (empty($regions)) {
         $this->regions = array(array('country' => '', 'county' => '', 'state' => '', 'city' => ''));
     } else {
         $this->regions = $regions;
     }
     $this->options = wp_parse_args($options, array('maxRegions' => 1, 'showTextField' => false, 'showExistingRegionsOnly' => get_awpcp_option('buildsearchdropdownlists'), 'hierarchy' => array('country', 'county', 'state', 'city'), 'enabled_fields' => awpcp_get_enabled_region_fields()));
     $this->options['maxRegions'] = max($this->options['maxRegions'], count($regions));
 }
Beispiel #13
0
/**
 * @since 3.4
 */
function awpcp_display_listings($query, $context, $options)
{
    $options = wp_parse_args($options, array('show_intro_message' => false, 'show_menu_items' => false, 'show_category_selector' => false, 'show_pagination' => false, 'before_content' => '', 'before_pagination' => '', 'before_list' => '', 'after_pagination' => '', 'after_content' => ''));
    if (has_action('awpcp_browse_ads_template_action') || has_filter('awpcp_browse_ads_template_filter')) {
        do_action('awpcp_browse_ads_template_action');
        return apply_filters('awpcp_browse_ads_template_filter');
    }
    $results_per_page = absint(awpcp_request_param('results', get_awpcp_option('adresultsperpage', 10)));
    $results_offset = absint(awpcp_request_param('offset', 0));
    if (empty($query['limit']) && $results_per_page) {
        $query['limit'] = $results_per_page;
    }
    if (empty($query['offset']) && $query['limit']) {
        $query['offset'] = $results_offset;
    }
    $listings_collection = awpcp_listings_collection();
    $listings = $listings_collection->find_enabled_listings_with_query($query);
    $listings_count = $listings_collection->count_enabled_listings_with_query($query);
    $before_content = apply_filters('awpcp-content-before-listings-page', $options['before_content'], $context);
    $before_pagination = array();
    if ($options['show_category_selector']) {
        $before_pagination[15]['category-selector'] = awpcp_render_category_selector(array('required' => false));
    }
    if (is_array($options['before_pagination'])) {
        $before_pagination = awpcp_array_merge_recursive($before_pagination, $options['before_pagination']);
    } else {
        $before_pagination[20]['user-content'] = $options['before_pagination'];
    }
    $before_pagination = apply_filters('awpcp-listings-before-content', $before_pagination, $context);
    ksort($before_pagination);
    $before_pagination = awpcp_flatten_array($before_pagination);
    $before_list = apply_filters('awpcp-display-ads-before-list', $options['before_list'], $context);
    if ($listings_count > 0) {
        $pagination_options = array('results' => $results_per_page, 'offset' => $results_offset, 'total' => $listings_count);
        $pagination = $options['show_pagination'] ? awpcp_pagination($pagination_options, awpcp_current_url()) : '';
        $items = awpcp_render_listings_items($listings, $context);
    } else {
        $pagination = '';
        $items = array();
    }
    $after_pagination = array('user-content' => $options['after_pagination']);
    $after_pagination = apply_filters('awpcp-listings-after-content', $after_pagination, $context);
    $after_content = apply_filters('awpcp-content-after-listings-page', $options['after_content'], $context);
    ob_start();
    include AWPCP_DIR . '/templates/frontend/listings.tpl.php';
    $content = ob_get_contents();
    ob_end_clean();
    return $content;
}
Beispiel #14
0
 public function create($args)
 {
     extract(wp_parse_args($args, array('enabled' => true, 'status' => null, 'is_primary' => false)));
     $image_mime_types = awpcp_get_image_mime_types();
     if (is_null($status)) {
         if (!awpcp_current_user_is_moderator() && in_array($mime_type, $image_mime_types) && get_awpcp_option('imagesapprove')) {
             $status = AWPCP_Media::STATUS_AWAITING_APPROVAL;
         } else {
             $status = AWPCP_Media::STATUS_APPROVED;
         }
     }
     $data = compact('ad_id', 'name', 'path', 'mime_type', 'enabled', 'status', 'is_primary');
     if ($insert_id = $this->save($data)) {
         return $this->find_by_id($insert_id);
     } else {
         return null;
     }
 }
 public function render($value, $errors, $listing, $context)
 {
     $characters_limit = $this->get_characters_limit_for_listing($listing);
     if ($characters_limit['characters_allowed'] == 0) {
         $characters_allowed_text = _x('No characters limit.', 'ad details form', 'AWPCP');
         $remaining_characters_text = '';
     } else {
         $characters_allowed_text = _x('characters left.', 'ad details form', 'AWPCP');
         $remaining_characters_text = $characters_limit['remaining_characters'];
     }
     if ($this->is_required()) {
         $validators = 'required';
     } else {
         $validators = '';
     }
     $params = array('required' => $this->is_required(), 'value' => $this->format_value($value), 'errors' => $errors, 'label' => $this->get_label(), 'help_text' => nl2br(get_awpcp_option('htmlstatustext')), 'validators' => $validators, 'characters_allowed' => $characters_limit['characters_allowed'], 'characters_allowed_text' => $characters_allowed_text, 'remaining_characters' => $characters_limit['remaining_characters'], 'remaining_characters_text' => $remaining_characters_text, 'html' => array('id' => str_replace('_', '-', $this->get_slug()), 'name' => $this->get_slug(), 'readonly' => false));
     return awpcp_render_template('frontend/form-fields/listing-details-form-field.tpl.php', $params);
 }
 private function render_shortcode_content($attrs)
 {
     extract($attrs);
     $category = $id > 0 ? AWPCP_Category::find_by_id($id) : null;
     $children = awpcp_parse_bool($children);
     if (is_null($category)) {
         return __('Category ID must be valid for Ads to display.', 'category shortcode', 'AWPCP');
     }
     if ($children) {
         $categories_list = awpcp_categories_list_renderer()->render(array('parent_category_id' => $category->id, 'show_listings_count' => true));
         $options = array('before_pagination' => array(10 => array('categories-list' => $categories_list)));
     } else {
         $options = array();
     }
     $query = array('context' => 'public-listings', 'category_id' => $category->id, 'include_listings_in_children_categories' => $children, 'limit' => absint($this->request->param('results', $items_per_page)), 'offset' => absint($this->request->param('offset', 0)), 'orderby' => get_awpcp_option('groupbrowseadsby'));
     // required so awpcp_display_ads shows the name of the current category
     $_REQUEST['category_id'] = $category->id;
     return awpcp_display_listings_in_page($query, 'category-shortcode', $options);
 }
Beispiel #17
0
<div id="classiwrapper">
    <?php 
if ($config['show_intro']) {
    ?>
    <div class="uiwelcome"><?php 
    echo stripslashes_deep(get_awpcp_option('uiwelcome'));
    ?>
</div>
    <?php 
}
?>

    <?php 
if ($config['show_menu']) {
    ?>
    <?php 
    echo awpcp_menu_items();
    ?>
    <?php 
}
?>

    <?php 
echo join('', $before_content);
?>

    <?php 
echo $pagination_block;
?>
    <div class="awpcp-listings awpcp-clearboth"><?php 
echo join('', $items);
Beispiel #18
0
/**
 * @since 3.4
 */
function awpcp_send_listing_was_flagged_notification($listing)
{
    if (!get_awpcp_option('send-listing-flagged-notification-to-administrators')) {
        return false;
    }
    $query_args = array('page' => 'awpcp-listings', 'filterby' => 'flagged', 'filter' => 1);
    $flagged_listings_url = add_query_arg($query_args, awpcp_get_admin_panel_url());
    $params = array('site_name' => get_bloginfo('name'), 'flagged_listings_url' => $flagged_listings_url);
    $template = AWPCP_DIR . '/templates/email/listing-was-flagged.plain.tpl.php';
    $mail = new AWPCP_Email();
    $mail->to = awpcp_admin_email_to();
    $mail->subject = str_replace('<listing-title>', $listing->get_title(), __('Listing <listing-title> was flagged', 'AWPCP'));
    $mail->prepare($template, $params);
    return $mail->send();
}
Beispiel #19
0
 public function upload_images_form($ad, $params = array())
 {
     $show_preview = (bool) get_awpcp_option('show-ad-preview-before-payment');
     $pay_first = (bool) get_awpcp_option('pay-before-place-ad');
     extract($params);
     if ($images_uploaded > 0 && $pay_first) {
         $next = __('Finish', 'AWPCP');
     } else {
         if ($images_uploaded == 0 && false == $pay_first && $show_preview) {
             $next = __('Preview Ad', 'AWPCP');
         } else {
             if ($images_uploaded == 0) {
                 $next = __('Place Ad', 'AWPCP');
             } else {
                 if ($show_preview) {
                     $next = __('Preview Ad', 'AWPCP');
                 } else {
                     $next = __('Checkout', 'AWPCP');
                 }
             }
         }
     }
     $params = array_merge($params, array('listing' => $ad, 'files' => awpcp_media_api()->find_by_ad_id($ad->ad_id), 'messages' => $this->messages, 'next' => $next));
     $template = AWPCP_DIR . '/frontend/templates/page-place-ad-upload-images-step.tpl.php';
     return $this->render($template, $params);
 }
Beispiel #20
0
function awpcp_create_captcha($type = 'default')
{
    switch ($type) {
        case 'recaptcha':
            $site_key = get_awpcp_option('recaptcha-public-key');
            $secret_key = get_awpcp_option('recaptcha-private-key');
            return new AWPCP_reCAPTCHA($site_key, $secret_key, awpcp_request());
        case 'default':
        default:
            $max = get_awpcp_option('math-captcha-max-number');
            return new AWPCP_DefaultCAPTCHA($max);
    }
}
        _e("The plugin has no associated page ID for the following pages. Please contact customer support.", 'AWPCP');
        ?>
</p>

				<ul>
				<?php 
        foreach ($missing['not-referenced'] as $page) {
            ?>
				<?php 
            $default = $awpcp->settings->get_option_default_value($page->page);
            ?>
				<?php 
            $message = __("Page: %s (Default name: %s).", 'AWPCP');
            ?>
				<?php 
            $message = sprintf($message, '<strong>' . get_awpcp_option($page->page) . '</strong>', $default);
            ?>
				<li><?php 
            echo $message;
            ?>
</li>
				<?php 
        }
        ?>
				</ul>
			<?php 
    }
    ?>
			</div>

			<?php 
Beispiel #22
0
/**
 * Resize images if they're too wide or too tall based on admin's Image Settings.
 * Requires both max width and max height to be set otherwise no resizing 
 * takes place. If the image exceeds either max width or max height then the 
 * image is resized proportionally.
 *
 * @deprecated 3.4
 */
function awpcp_resizer($filename, $dir)
{
    $maxwidth = get_awpcp_option('imgmaxwidth');
    $maxheight = get_awpcp_option('imgmaxheight');
    if ('' == trim($maxheight) || '' == trim($maxwidth)) {
        return false;
    }
    $parts = awpcp_utf8_pathinfo($filename);
    if ('jpg' == $parts['extension'] || 'jpeg' == $parts['extension']) {
        $src = imagecreatefromjpeg($dir . $filename);
    } else {
        if ('png' == $parts['extension']) {
            $src = imagecreatefrompng($dir . $filename);
        } else {
            $src = imagecreatefromgif($dir . $filename);
        }
    }
    list($width, $height) = getimagesize($dir . $filename);
    if ($width < $maxwidth && $height < $maxheight) {
        return true;
    }
    $newwidth = '';
    $newheight = '';
    $aspect_ratio = (double) $height / $width;
    $newheight = $maxheight;
    $newwidth = round($newheight / $aspect_ratio);
    if ($newwidth > $maxwidth) {
        $newwidth = $maxwidth;
        $newheight = round($newwidth * $aspect_ratio);
    }
    $tmp = imagecreatetruecolor($newwidth, $newheight);
    imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
    $newname = $dir . $filename;
    switch ($parts['extension']) {
        case 'gif':
            @imagegif($tmp, $newname);
            break;
        case 'png':
            @imagepng($tmp, $newname, 0);
            break;
        case 'jpg':
        case 'jpeg':
            @imagejpeg($tmp, $newname, 100);
            break;
    }
    imagedestroy($src);
    imagedestroy($tmp);
    return true;
}
 private function render_payment_button($transaction)
 {
     global $awpcp_imagesurl;
     // no current support for multiple items
     $item = $transaction->get_item(0);
     $is_recurring = get_awpcp_option('paypalpaymentsrecurring');
     $is_test_mode_enabled = get_awpcp_option('paylivetestmode') == 1;
     $currency = get_awpcp_option('paypalcurrencycode');
     $custom = $transaction->id;
     $totals = $transaction->get_totals();
     $amount = $totals['money'];
     $payments = awpcp_payments_api();
     $return_url = $payments->get_return_url($transaction);
     $notify_url = $payments->get_notify_url($transaction);
     $cancel_url = $payments->get_cancel_url($transaction);
     $paypal_url = $is_test_mode_enabled ? self::SANDBOX_URL : self::PAYPAL_URL;
     ob_start();
     include AWPCP_DIR . '/frontend/templates/payments-paypal-payment-button.tpl.php';
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
echo $value;
?>
" name="title_characters"></span>
                    <span class="helptext"><?php 
_e('0 means no limit.', 'AWPCP');
?>
</span>
                </label>

                <label class="clearfix">
                    <span class="title"><?php 
_e('Characters in Description', 'AWPCP');
?>
</span>
                    <?php 
$value = $fee ? $fee->get_characters_allowed() : get_awpcp_option('maxcharactersallowed', 0);
?>
                    <span class="input-text-wrap"><input type="text" value="<?php 
echo $value;
?>
" name="characters"></span>
                    <span class="helptext"><?php 
_e('0 means no limit.', 'AWPCP');
?>
</span>
                </label>

                <?php 
if (function_exists('awpcp_featured_ads')) {
    ?>
                <label class="alignleft">
Beispiel #25
0
 protected function render_all_listings()
 {
     $query = array('context' => 'public-listings', 'limit' => absint(awpcp_request_param('results', get_awpcp_option('adresultsperpage', 10))), 'offset' => absint(awpcp_request_param('offset', 0)), 'orderby' => get_awpcp_option('groupbrowseadsby'));
     return awpcp_display_listings_in_page($query, 'browse-listings');
 }
Beispiel #26
0
function awpcp_get_menu_items()
{
    $items = array();
    $user_is_allowed_to_place_ads = !get_awpcp_option('onlyadmincanplaceads') || awpcp_current_user_is_admin();
    $show_place_ad_item = $user_is_allowed_to_place_ads && get_awpcp_option('show-menu-item-place-ad');
    $show_edit_ad_item = $user_is_allowed_to_place_ads && get_awpcp_option('show-menu-item-edit-ad');
    $show_browse_ads_item = get_awpcp_option('show-menu-item-browse-ads');
    $show_search_ads_item = get_awpcp_option('show-menu-item-search-ads');
    if ($show_place_ad_item) {
        $place_ad_url = awpcp_get_page_url('place-ad-page-name');
        $place_ad_page_name = get_awpcp_option('place-ad-page-name');
        $items['post-listing'] = array('url' => $place_ad_url, 'title' => esc_html($place_ad_page_name));
    }
    if ($show_edit_ad_item) {
        $items['edit-listing'] = awpcp_get_edit_listing_menu_item();
    }
    if ($show_browse_ads_item) {
        if (is_awpcp_browse_listings_page() || is_awpcp_browse_categories_page()) {
            if (get_awpcp_option('main_page_display')) {
                $browse_cats_url = awpcp_get_view_categories_url();
            } else {
                $browse_cats_url = awpcp_get_main_page_url();
            }
            $view_categories_page_name = get_awpcp_option('view-categories-page-name');
            $items['browse-listings'] = array('url' => $browse_cats_url, 'title' => esc_html($view_categories_page_name));
        } else {
            $browse_ads_page_name = get_awpcp_option('browse-ads-page-name');
            $browse_ads_url = awpcp_get_page_url('browse-ads-page-name');
            $items['browse-listings'] = array('url' => $browse_ads_url, 'title' => esc_html($browse_ads_page_name));
        }
    }
    if ($show_search_ads_item) {
        $search_ads_page_name = get_awpcp_option('search-ads-page-name');
        $search_ads_url = awpcp_get_page_url('search-ads-page-name');
        $items['search-listings'] = array('url' => $search_ads_url, 'title' => esc_html($search_ads_page_name));
    }
    $items = apply_filters('awpcp_menu_items', $items);
    return $items;
}
Beispiel #27
0
 protected function process_contact_form()
 {
     global $nameofsite;
     $ad = $this->get_ad();
     $form = array_merge($this->get_posted_data(), array('ad_id' => $ad->ad_id));
     $errors = array();
     if (!$this->validate_posted_data($form, $errors)) {
         return $this->contact_form($form, $errors);
     }
     $ad_title = $ad->get_title();
     $ad_url = url_showad($ad->ad_id);
     $sender_name = stripslashes($form['awpcp_sender_name']);
     $sender_email = stripslashes($form['awpcp_sender_email']);
     $message = awpcp_strip_html_tags(stripslashes($form['awpcp_contact_message']));
     if (get_awpcp_option('usesenderemailinsteadofadmin')) {
         $sender = awpcp_strip_html_tags($sender_name);
         $from = $sender_email;
     } else {
         $sender = $nameofsite;
         $from = awpcp_admin_sender_email_address();
     }
     /* send email to admin */
     if (get_awpcp_option('notify-admin-about-contact-message')) {
         $subject = __('Notification about a response regarding Ad: %s', 'AWPCP');
         $subject = sprintf($subject, $ad_title);
         ob_start();
         include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-admin.tpl.php';
         $admin_body = ob_get_contents();
         ob_end_clean();
         $admin_email = awpcp_admin_recipient_email_address();
         $result = awpcp_process_mail($from, $admin_email, $subject, $admin_body, $sender, $sender_email);
     }
     $subject = sprintf("%s %s: %s", get_awpcp_option('contactformsubjectline'), _x('regarding', 'reply email', 'AWPCP'), $ad_title);
     ob_start();
     include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-user.tpl.php';
     $body = ob_get_contents();
     ob_end_clean();
     $sendtoemail = get_adposteremail($ad->ad_id);
     $result = awpcp_process_mail($from, $sendtoemail, trim($subject), $body, $sender, $sender_email);
     if ($result) {
         $message = __("Your message has been sent.", "AWPCP");
         return $this->render('content', awpcp_print_message($message));
     } else {
         $this->messages[] = __("There was a problem encountered during the attempt to send your message. Please try again and if the problem persists, please contact the system administrator.", "AWPCP");
         return $this->contact_form($form, $errors);
     }
 }
 public function render()
 {
     $option_name = 'hide-all-payment-terms-if-no-category-is-selected';
     awpcp()->js->set($option_name, awpcp_parse_bool(get_awpcp_option($option_name)));
     ob_start();
     include AWPCP_DIR . '/frontend/templates/payments-payment-terms-table.tpl.php';
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
    ?>
</label>
            <?php 
    echo awpcp_form_error('terms-of-service', $errors);
    ?>
        </p>
        <?php 
}
?>

        <?php 
if ($ui['captcha']) {
    ?>
        <div class='awpcp-form-spacer'>
            <?php 
    $captcha = awpcp_create_captcha(get_awpcp_option('captcha-provider'));
    ?>
            <?php 
    echo $captcha->render();
    ?>
            <?php 
    echo awpcp_form_error('captcha', $errors);
    ?>
        </div>
        <?php 
}
?>

        <?php 
if ($preview) {
    ?>
Beispiel #30
0
 public function render_transaction_items($transaction)
 {
     $show_credits = get_awpcp_option('enable-credit-system');
     ob_start();
     include AWPCP_DIR . '/frontend/templates/payments-transaction-items-table.tpl.php';
     $html = ob_get_contents();
     ob_end_clean();
     return apply_filters('awpcp-render-transaction-items', $html, $transaction);
 }